Recently I needed to automate the addition of the addition of a script defined in a package.json
‘s scripts
section. To do this I used npm-add-script
(an older, but still functioning project), along with the aforementioned npx
.
For example, to add a script labelled start
with the contents webpack-dev-server --config ./config/webpack.config.babel.js --env.MODE=development --open --hot
, I use:
npx npm-add-script \
-k "start" \
-v "webpack-dev-server --config ./config/webpack.config.babel.js --env.MODE=development --open --hot" \
--force
Using the --force
I enforce overwriting of any existing start
script.
Thank me with a coffee.
I don\'t do this for profit but a small one-time donation would surely put a smile on my face. Thanks!
To stay in the loop you can follow @bramus or follow @bramusblog on Twitter.