Reputation: 73
I'm trying to making a new project,
I'm using here gulpfile.ja
code
const gulp = require('gulp');
const browserSync = require('browser-sync').create();
const sass = require('gulp-sass');
// Compile SASS
gulp.task('sass', function(){
return gulp.src(['node_modules/bootstrap/scss/bootstrap.scss', 'src/scss/*.scss'])
.pipe(sass())
.pipe(gulp.dest("src/css"))
.pipe(browserSync.stream());
});
// Move JS Files to SRC
gulp.task('js', function(){
return gulp.src(['node_modules/bootstrap/dist/js/bootstrap.min.js', 'node_modules/jquery/dist/jquery.min.js', 'node_modules/tether/dist/js/tether.min.js'])
.pipe(gulp.dest("src/js"))
.pipe(browserSync.stream());
});
// Watch SASS & Serve
gulp.task('serve', ['sass'], function(){
browserSync.init({
server: "./src"
});
gulp.watch(['node_modules/bootstrap/scss/bootstrap.scss', 'src/scss/*.scss'], ['sass']);
gulp.watch("src/*.html").on('change', browserSync.reload);
});
// Move Font Awesome Fonts folder to src
gulp.task('fonts', function(){
return gulp.src('node_modules/font-awesome/fonts/*')
.pipe(gulp.dest("src/fonts"));
});
// Move font awesome css file
gulp.task('fa', function(){
return gulp.src('node_modules/font-awesome/css/font-awesome.min.css')
.pipe(gulp.dest("src/css"));
});
gulp.task('default', ['js', 'serve', 'fa', 'fonts']);
but when I'm running gulp
on my command line here showing an error like
assert.js:60
throw new errors.AssertionError({
^
AssertionError [ERR_ASSERTION]: Task function must be specified
at Gulp.set [as _setTask] (D:\PracticeJob\bs4practice\node_modules\undertaker\lib\set-task.js:10:3)
at Gulp.task (D:\PracticeJob\bs4practice\node_modules\undertaker\lib\task.js:13:8)
at Object.<anonymous> (D:\PracticeJob\bs4practice\gulpfile.js:21:6)
at Module._compile (module.js:569:30)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
at Module.require (module.js:513:17)
at require (internal/module.js:11:18)
Upvotes: 0
Views: 475
Reputation: 181449
This is not allowed in gulp4:
gulp.task('default', ['js', 'serve', 'fa', 'fonts']);
Change to:
gulp.task('default', gulp.series('js', 'serve', 'fa', 'fonts');
Same with this:
gulp.task('serve', ['sass'], function(){
Change to:
gulp.task('serve', gulp.series('sass', function(){
And change to:
gulp.watch(['node_modules/bootstrap/scss/bootstrap.scss', 'src/scss/*.scss'], 'sass');
You cannot just use gulp3 code in a gulp4 environment without making these changes. The above are the mimimum changes you must make but there are many more you should make to fully utilize gulp4. See, e.g., gulp4 documentation: creating tasks.
Upvotes: 2