I have recently updated gulp to 4+ version and then gulp does not start the watch tasks anymore. What am i doing wrong? below here is the updated version of code gulp 3+ to gulp 4, I am using gulp.series as per gulp4 docs.
npm run build
command would have previously copied over the assets folder to 2 other places, its not anymore starting the gulp tasks and gulp watch.
Given myGulpFile.js
var gulp = require('gulp');
var path = require('path');
gulp.task('copytask', function() {
gulp.src(['assets/**/*']).pipe(gulp.dest('buildpath/assets'))
.pipe(gulp.dest(path.resolve(__dirname, '../somepath/assets')));
});
gulp.task('watchtask', gulp.series( function watchtask(){
gulp.watch('assets/**/*', gulp.series('copytask'));
}));
gulp.task('default',gulp.series('watchtask', function (done) {
console.log("Gulp started now from webpack!!");
done();
}));
Given my package.json for webpack
"main": "webpack.config.js",
"scripts": {
"build": "webpack --progress -c",
"watch": "webpack -w --progress -c",
"dev": "webpack-dev-server --devtool eval --progress --colors --content-base build",
"deploy": "NODE_ENV=production webpack --config webpack.production.config.js"
},
and my webpack.config.js
var webpack = require('webpack');
var something ...;
require('./myGulpFile');
var config = {
...
}
module.exports = config;
any help regarding this is much appreciated!
EDIT: To further clarify my question, I want to run gulp by running just one of the webpack commands and automatically start the gulp tasks (this was happening in gulp3+ version using above procedure) but broke after updating to gulp4 version.
Its working now, I ended up changing package.json commands and adding && gulp -f myGulpFile.js
to the end of the build,dev,deploy commands as below. This will start the gulp tasks right after the webpack commands and you only have to run one initial webpack command npm run build
"scripts": {
"build": "webpack --progress -c && gulp -f myGulpFile.js",
"watch": "webpack -w --progress -c",
"dev": "webpack-dev-server --devtool eval --progress --colors --content-base build && gulp -f myGulpFile.js",
"deploy": "NODE_ENV=production webpack --config webpack.production.config.js && gulp -f myGulpFile.js"
}, ```