Final steps

Before we finish, let's also document the commands we've run into npm scripts. This will make building and serving our application easier in the future.

In the package.json, define the build step with the following scripts property:

"scripts": {  "build": "rm -rf dist/ && webpack"}

Then, we will write a script to serve our application. We'd like to specify the host and port of the application using environment variables (instead of hard-coding it), so let's create an .env and an .env.example file, and fill them with the following content:

WEB_SERVER_PORT_TEST=8200WEB_SERVER_HOST_TEST=localhost

Then, create a Bash script at scripts/serve.sh and give it the execute permission:

$ mkdir scripts && touch scripts/serve.sh$ chmod u+x ...

Get Building Enterprise JavaScript Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.