In my package.json I'm trying to use webpack
in a script but it keeps failing.
"scripts": { "start": "node server.js", "test": "mocha 'src/**/test*.coffee' --watch --compilers coffee:coffee-script/register", "build": "webpack --config webpack.dist.config.js" },
the scripts start
and test
works as expected but when running npm build
in terminal I'm getting nothing:
➜ client git:(master) ✗ npm build ➜ client git:(master) ✗
When running the command manually, things happen:
➜ client git:(master) ✗ webpack --config webpack.dist.config.js Hash: 9274a04acd39605afc25 Version: webpack 1.9.10 Time: 5206ms Asset Size Chunks Chunk Names bundle.js 5.23 MB 0 [emitted] main [0] multi main 28 bytes {0} [built] [349] ../config.js 181 bytes {0} [built] + 413 hidden modules ➜ client git:(master) ✗
Have I miss understod how npm scripts are suppose to work?
Webpack is used to compile JavaScript modules. Once installed, you can interact with webpack either from its CLI or API. If you're still new to webpack, please read through the core concepts and this comparison to learn why you might use it over the other tools that are out in the community.
The easiest way to get your webpack. config. js file to work is to place it at the top level of your project's folder structure along with your package.
Use: npm run build
Reason: npm start
& npm test
are shortcuts for npm run start
& npm run test
, for any other npm tasks, you have to specify "run"
Run npm run build
.
start
and test
are built in scripts for npm
. build
however is a custom script and thus needs to be invoked with npm run build
.
You can find out more about npm's scripts here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With