Build Scripts
Let’s learn how to add the build script in our project's package.json file.
We'll cover the following
NPM scripts
To make it easier to build our application for both development and production use, we can add build instructions to the npm package.json
file. We’ll usually want to specify different build options depending on which environment we are building for. For example, while it is nice to have a readable, non-minified generated JavaScript code and have sourcemaps available for debugging purposes, we would usually not want to do this for production because we want the file sizes sent to the browser to be as small as possible.
We can add named scripts to the package.json
file that we can call whenever we want to build our application for a specific environment. In the scripts section of the package.json
file, add these two lines right before the existing test script. When adding these lines, note that line breaks are not allowed in JSON strings:
Get hands-on with 1200+ tech skills courses.