This is what I use for small npm script based projects: I simply run npm start
and start working ;)
concurrently
launches the corresponding tasks in parallel
node-sass
is responsible for the sass->css generation
- it needs to reran the sass task with the
--watch
option for monitoring of
sass
related changes
- and finally
lite-server
starts the server with the build-in live-reload support. By default, it watches for changes for the following file extensions: html,htm,css,js
, but everything can be easily adjusted with the configuration files bs-config.json
or bs-config.js
.
Relevant parts of the package.json
:
...
"scripts": {
"start": "concurrently --names \"SASS,WATCH,SERVE\" -c \"bgBlue.bold,bgMagenta.bold,bgGreen.bold\" \"npm run sass\" \"npm run sass:watch\" \"npm run serve\"",
"serve": "lite-server",
"sass": "node-sass style.sass --output ./ --indent-width 4 --output-style expanded --indent-type space --source-map true",
"sass:watch": "npm run sass -- --watch"
},
...
"devDependencies": {
"lite-server": "^2.2.2",
"concurrently": "^3.5.0",
"node-sass": "^4.5.3"
}
This works well for me on Windows 10 and as well as on the GNU/Linux based distros like Ubuntu.
live-reload
is it? There is this one that seems not have a npmrun
. Or am I missing something.. – Rathe