I am trying to create a script in my package.json file that will launch my nodemon app, then trigger a gulp sass watch
Currently, I can do this by running a npm launch
which starts nodemon, then in a separate terminal window I can run gulp watch
to trigger the sass watch from my gulp file.
I would like to create a single script command in package.json that will do both of these- is that possible?
package.json
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "nodemon app.js",
"launch": "nodemon app.js && gulp watch"
},
gulpfile.js
const { src, dest, watch } = require("gulp");
const sass = require('gulp-sass')(require('node-sass'));
function generateCSS(cb) {
src('./sass/**/*.scss')
.pipe(sass().on('error', sass.logError))
.pipe(dest('public/css'));
cb();
}
function watchFiles(cb) {
watch('sass/**/**.scss', generateCSS);
}
exports.css = generateCSS;
exports.watch = watchFiles;
edit: please see my answer below for what worked for me, inspired by the answer from @cmgchess