While playing with
cssnext I decided to use npm
scripts instead of relying on a build
system. One of the benefits of using scripts, other than having fewer
dependencies in your project, is that the
node_modules/.bin directory gets
added to your PATH. This
makes it easy to work with modules that you only use for development.
scripts field from the
distare “shortcuts” for the other scripts.
setuptakes care of clearing and creating the
cssruns the CSS file through cssnext and compresses the output.
htmlcopies the HTML file.
distfolder to the
To run a script you run
npm run <script>.
start also has a shortcut, which
npm start. If you can’t remember the name of a script you can list them all
A note on Windows support
On my Windows machine I use Git Bash, which
gives me access to common UNIX tools. You can use modules like
ncp as replacements for
cp -r to make the scripts more portable.