Sunday, 28 May 2017

NPM Scripts using watch works in CLI but breaks in npm scripts

I'm trying to set up the following scripts on Windows 10 (using git bash, MINGW):

...
"sass:build": "cat assets/styles/* | node-sass | postcss --no-map -u autoprefixer -u cssnano > dist/public/styles/styles.css.min",
"sass:watch": "watch sass:build ./assets/styles/",
...

After running npm i --save-dev node-sass postcss autoprefixer cssnano watch I get this error:

$ npm run sass:watch

> thenewells@0.0.0 sass:watch C:\repos\thenewells
> watch sass:build ./assets/styles/

>Watching ./assets/styles/
The filename, directory name, or volume label syntax is incorrect.

But if I do npm i -g node-sass postcss autoprefixer cssnano watch then this happens...

$ watch 'npm run sass:build' ./assets/styles/

> Watching ./assets/styles/

> thenewells@0.0.0 sass:build C:\repos\thenewells
> cat assets/styles/* | node-sass | postcss --no-map -u autoprefixer -u cssnano dist/public/styles/styles.css.min

√ Finished stdin (373ms)

Why is is different?



via Sean Newell

No comments:

Post a Comment