Creating npm Scripts for Development

In your package.json file you should have a scripts section. If you generated the file with the npm init defaults you’ll have a placeholder "test" script in there. You should change that to work with Jest.

Add more scripts in there to build the scripts with runner for Webpack.

{
 // ...
 "scripts": {
    "build:dev": "webpack --stats verbose",
    "build:prd": "webpack build --config ./webpack.config.prd.js --stats verbose",
    "build:watch": "webpack --watch",
    "test": "jest"
 },

The --mode=development flag is to make Webpack generate a development-friendly bundle. Run Webpack with --mode=production in production.

The --watch flag in the command above is to run Webpack in watch mode 

Command Line Interface | webpack

Comments

Leave a Comment

All fields are required. Your email address will not be published.