Npm build for a specific IP address

I am at a point where I want to build a dist package (I don’t know if that’s the right term) for my application to test it out.

I see where you can use either au build or npm build, but I am unsure what to do after that?

Do I need to create a webserver to serve the application on?

Do I need to build it for a specific IP address?

Right now I run au run --host [ip address] to test things out.

Any guidance would be appreciated.

Yep you need a webserver. For a quick approach try installing http-server which spins up a simple one-off host. Ultimately you want to serve your app though either standalone via e.g. nginx or as static part of a backend

If you are using webpack, the npm run build will build everything in dist/ folder, it has an index.html file and all js/css bundles. You would need to copy all those files to a http server root folder.

  • dist/index.html to root/index.html
  • dist/appxxx.js to root/appxxx.js

If you are using cli built-in bundler, the npm run build will build index.html file in your project folder, and all js bundles in dist/ folder. You would need to copy all those files to http server root folder following the folder structure.

  • index.html to root/index.html
  • dist/xxx-bundle.js to root/dist/xxx-bundle.js

Before deploy to production, you can use a local server (http-server as zewa666 suggested) to test it out.

npm i -g http-server

Then run http-server inside dist/ folder for webpack, or run inside just project folder for cli built-in bundler.

1 Like