Kokodoko Kokodoko - 1 year ago 93
CSS Question

Can I run watchify and node-sass watch at the same time?

I am using npm scripts with watchify and node-sass with the -w parameter.

Can I simply run these two 'watch' commands at the same time? Will only the style.css get compiled when the scss changes, and only the bundle.js get compiled when the javascript source changes?

"scripts": {
"watch-js":"watchify dev/index.js -o dist/bundle.js",
"watch-css": "node-sass -w my-styles.scss style.css",
"thewatcher": "npm run watch-js & npm run watch-css"

Answer Source

Yes, that is exactly what is going to happen. Script "thewatcher" will run "watch-js" and "watch-css" independently. Watchify will only listen to changes made to dev/index.js and node-sass will only listen to changes made to my-styles.scss. If you want to know exactly when a new dist/bundle.js file has been written, modify your "watch-js" script to include the -v flag:

"watch-js":"watchify dev/index.js -o dist/bundle.js -v"