npm scriptsare low-level and leverage the actual library you want to use (example:"lint": "eslint ./")package.jsonis a central place to see what scripts are available (alsonpm runwill list all scripts)- When things get too complicated you can always defer to another file (example:
"complex-script": "babel-node tools/complex-script.js") npm scriptsare more powerful than one might first think (pre/post hooks, passing arguments, config variables, chaining, piping, etc...)- We aren't tied to a specific build abstraction (Anvil, brocolli, Grunt, Gulp) when the next big thing comes out.
- Not everyone is familiar with
npm scripts - Some scripts can get lengthy and cumbersome
npm-run-all: A CLI tool to run multiple npm-scripts in parallel or sequential.rimraf: A deep deletion module for node (likerm -rf)onchange: Use glob patterns to watch file sets and run a command when anything is added, changed or deleted.
- There are lots of Gulp plugins and utilities
- We already have some helper libraries to provide common Gulp tasks
- Gulp plugins often get out of date and don’t support new features from the underlying library
- You become dependant on the Gulp plugin author and not the library that is being wrapped
- Documentation for Gulp plugins are typically not very robust or comprehensive
- Debugging a Gulp plugin can be frustrating. Is the problem in the plugin or in the underlying library?
- If a plugin doesn't exist already for Gulp you need to write it yourself
- Errors that occur inside a Gulp wrapper arean't always handled very well
- Do we switch to
npm scriptsonly, keep using Gulp, or have a mixture of the two? - If we have a mixture of
npm scriptsand Gulp, how do we decide when to use what? Do we start with an assumption ofnpm scriptsuntil a certain complexity threshold is met? Do we only usenpm scriptsfor new projects and then split out totools/script-file.jswhen the complexity gets high? (See react-slingshot for an example) - How do we reconcile projects that have Gulp already in them? Do we keep updating them or do we consider switching them to
npm scriptsif we find we keep updating them?
Thank you for writing this. I am trying to understand how npm scripts work because Bootstrap 4 is planning to switch to this. Do you know any good learning resources for this?