Hi there,
I’m new to Gulp and full of pride I’ve created my first series of tasks
However I would like to optimize my file a little bit and searching for advice.
This is my gulpfile.js
const { cssCompile, cssMinify, cssConcat, cssCleanTemp } = require("./gulp_tasks/css-compile.js");`
const { watch } = require("./gulp_tasks/watch.js");
const gulp = require('gulp');
module.exports = {
'css-create': gulp.series(cssCleanTemp, cssCompile, cssConcat, cssMinify),
'watch': gulp.series(watch)
}
and this is my watch.js
const { cssCompile, cssMinify, cssConcat, cssCleanTemp } = require('./css-compile.js');
const watch = function (done) {
gulp.watch(config.css.watch, gulp.series(cssCleanTemp, cssCompile, cssConcat, cssMinify));
done();
}
module.exports = {
watch
}
As you can see I’m repeating the whole series in my main gulpflile.js
and in my watch.js
.
Question
How can I optimize this? Ideally I would like to do something like this in my gulpfile.js
'watch': gulp.series('css-create')
But this obviously doesn’t work.
Thanks in advance.
Peter