package.json
file. These can then execute tasks using the NPM CLI.scripts
property of the package.json
file. For example:pre
or post
respectively to the task name. Here, our prebuild
task is executed before our build
task.We can run an NPM script from inside another NPM script.
build
script we run the command npm run build
:prebuild
task executes. prebuild
task runs the clean
task, which executes the rimraf dist
command. rimraf
(an NPM package) recursively deletes everything inside a specified folder.build
task is executed. This sets the NODE_ENV
environment variable to production
and starts the webpack bundling process.webpack.config.js
available in the project root folder.