After rewriting this boilerplate build and watch scripts over and over again, I've finally compiled it into a cloneable repo.
Original inspiration from Task Automation with Npm Run. Lots of improvements and further inspiration from How to Use npm as a Build Tool.
Run npm install
to fetch dependencies and to install git hooks. Git hooks are used for linting and running tests before pushing and merging.
npm run watch
builds withNODE_ENV=dev
. Watches files in/src
. Rebuilds on every change.npm run build
makes a build withNODE_ENV=production
.npm run test
runs all in/src
which matches*.spec.js
using tape.
Files are built with a version suffix into /pub/
, e.g. pub/bundle-1.0.0.js
.
An AppCache Manifest file is also built. All files in /pub
are included in the files list.
All watch tasks make use of:
For /src/**/*.html
the strings __VERSION__
and __MANIFEST__
in the source are replaced with the version number and the manifest file name from package.json
respectively.
To compile the HTML and AppCache manifest, find
and sed
are used.