I am using multiple files with gulp@4
where the main gulpfile.js
includes all other files within the ./tasks/
directory. We are using the npm gulp-hub package to include multiple gulpfiles
with the ./tasks/
directory. However we are getting the following error message when calling the tasks
.
Forward referenced tasks 'clean-minify-js` not defined before use
How can we include multiple gulpfiles
within the main gulpfile.js
so that we can call tasks
?
Current gulpfile.js
:
'use strict';
var gulp = require('gulp'),
HubRegistry = require('gulp-hub');
var genericHub = new HubRegistry('./tasks/scripts.js');
gulp.registry(genericHub);
var watchers = function(done) {
gulp.watch('src/*.js', gulp.parallel('clean-minify-js'));
done();
}
gulp.task('watch', gulp.series(watchers));
Current ./tasks/scripts.js
'use strict';
var gulp = require('gulp'),
clean = require('gulp-clean'),
uglify = require('gulp-uglify');
gulp.task('clean-scripts', function() {
return gulp.src(dest.js)
.pipe(clean({read:false, force: true});
});
gulp.task('minify-js', gulp.series('clean-scripts', function() {
gulp.src(src.js)
.pipe(uglify())
.pipe(gulp.dest(dest.js));
}));
gulp.task('clean-minify-js', gulp.series('minify-js'));
Folder structure:
some/path/gulpfile.js
some/path/tasks/scripts.js