How to rebuild webpack bundle only if sources were changed
First install NPM package named build-if-changed
npm install -g build-if- changed In root folder (near package.json
) create file buildconfig
: [cross-env NODE_ENV='production' && webpack -p --progress] out: ../static/ .js src/ / .json.js src
is folder with all sources and ../static/
is folder where build.js
result file is genereted. Most likely it will have different value for you. I took it from my webpack.config.js
: const path = require('path'); return { output: { path: path.join(__dirname, '..', 'static'), filename: 'build.js' ... } ... Ready. You can just run build-if- changed
in your folder. Or add next command to pacakge.json
scripts section to be able to execute npm run fastbundle
: "scripts": { ... "fastbundle": "build-if-changed" }