I am new to using Gulp and I am in the process of creating a gulpfile to minify and merge css
and js
files. However, when I try to run the command gulp
, I encounter the following error:
C:\Users\S.Hocine\Desktop\gulpTest>gulp
AssertionError [ERR_ASSERTION]: Task function must be specified
at Gulp.set [as _setTask] (C:\Users\S.Hocine\Desktop\gulpTest\node_modules\undertaker\lib\set-task.js:10:3)
at Gulp.task (C:\Users\S.Hocine\Desktop\gulpTest\node_modules\undertaker\lib\task.js:13:8)
at Object.<anonymous> (C:\Users\S.Hocine\Desktop\gulpTest\gulpfile.js:36:6)
at Module._compile (internal/modules/cjs/loader.js:1156:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1176:10)
at Module.load (internal/modules/cjs/loader.js:1000:32)
at Function.Module._load (internal/modules/cjs/loader.js:899:14)
at Module.require (internal/modules/cjs/loader.js:1042:19)
at require (internal/modules/cjs/helpers.js:77:18)
at requireOrImport (C:\Users\S.Hocine\AppData\Roaming\npm\node_modules\gulp-cli\lib\shared\require-or-import.js:19:11) {
generatedMessage: false,
code: 'ERR_ASSERTION',
actual: false,
expected: true,
operator: '=='
}
Here is my gulpfile:
const gulp = require('gulp');
const uglify = require('gulp-uglify');
const concat = require('gulp-concat');
// Minify and copy html
gulp.task('minifyHtml', function(){
gulp.src('src/*.html')
.pipe(uglify())
.pipe(gulp.dest('dest'));
});
// Minify and merge css
gulp.task('minifyMergeCss', function(){
gulp.src('src/css/*.css')
.pipe(concat('merged-min.css'))
.pipe(uglify())
.pipe(gulp.dest('dest/css'));
});
// Minify and merge js
gulp.task('minifyMergeJs', function(){
gulp.src('src/js/*.js')
.pipe(concat('merged-min.js'))
.pipe(uglify())
.pipe(gulp.dest('dest/js'));
});
gulp.task('default', ['minifyHtml', 'minifyMergeCss', 'minifyMergeJs']);
gulp.task('watch', function(){
gulp.watch('src/*.html', ['minifyHtml']);
gulp.watch('src/css/*.css', ['minifyMergeCss']);
gulp.watch('src/js/*.js', ['minifyMergeJs']);
});
My gulp version:
CLI version: 2.3.0
Local version: 4.0.2
Can you help me identify the problem?