admin管理员组文章数量:1415697
I am attempting to refactor some legacy code I wrote 2 years ago. A gulpfile.js
file to be precise.
It seems like the problem is here:
// gulp.task('default', ['browserify', 'copy'], function() {
// return gulp.watch('src/**/*.*', ['browserify', 'copy']);
// });
I mented it out and replaced it with this:
gulp.task('default', gulp.series('browserify', 'copy'), function() {
return gulp.watch('src/**/*.*', ['browserify', 'copy']);
});
Not good enough. The whole file looks like this:
var gulp = require('gulp');
var browserify = require('browserify');
var reactify = require('reactify'); // Converts jsx to js
var source = require('vinyl-source-stream'); // Converts string to a stream
gulp.task('browserify', function() {
browserify('./src/js/main.js')
.transform('reactify')
.bundle()
.pipe(source('main.js'))
.pipe(gulp.dest('dist/js'));
});
gulp.task('copy', function() {
gulp.src('src/index.html').pipe(gulp.dest('dist'));
gulp.src('src/css/*.*').pipe(gulp.dest('dist/css'));
gulp.src('src/images/*.*').pipe(gulp.dest('dist/images'));
gulp.src('src/js/vendors/*.*').pipe(gulp.dest('dist/js'));
});
// gulp.task('default', ['browserify', 'copy'], function() {
// return gulp.watch('src/**/*.*', ['browserify', 'copy']);
// });
gulp.task('default', gulp.series('browserify', 'copy'), function() {
return gulp.watch('src/**/*.*', ['browserify', 'copy']);
});
I have read through some of the getting started documentation, but what I have read thus far has not helped me refactor this.
I am attempting to refactor some legacy code I wrote 2 years ago. A gulpfile.js
file to be precise.
It seems like the problem is here:
// gulp.task('default', ['browserify', 'copy'], function() {
// return gulp.watch('src/**/*.*', ['browserify', 'copy']);
// });
I mented it out and replaced it with this:
gulp.task('default', gulp.series('browserify', 'copy'), function() {
return gulp.watch('src/**/*.*', ['browserify', 'copy']);
});
Not good enough. The whole file looks like this:
var gulp = require('gulp');
var browserify = require('browserify');
var reactify = require('reactify'); // Converts jsx to js
var source = require('vinyl-source-stream'); // Converts string to a stream
gulp.task('browserify', function() {
browserify('./src/js/main.js')
.transform('reactify')
.bundle()
.pipe(source('main.js'))
.pipe(gulp.dest('dist/js'));
});
gulp.task('copy', function() {
gulp.src('src/index.html').pipe(gulp.dest('dist'));
gulp.src('src/css/*.*').pipe(gulp.dest('dist/css'));
gulp.src('src/images/*.*').pipe(gulp.dest('dist/images'));
gulp.src('src/js/vendors/*.*').pipe(gulp.dest('dist/js'));
});
// gulp.task('default', ['browserify', 'copy'], function() {
// return gulp.watch('src/**/*.*', ['browserify', 'copy']);
// });
gulp.task('default', gulp.series('browserify', 'copy'), function() {
return gulp.watch('src/**/*.*', ['browserify', 'copy']);
});
I have read through some of the getting started documentation, but what I have read thus far has not helped me refactor this.
Share Improve this question asked Nov 22, 2018 at 20:46 DanielDaniel 15.6k19 gold badges114 silver badges182 bronze badges2 Answers
Reset to default 5With Gulp 4.0 the way you run tasks in series has got changed. You can read and get what you want using below link https://github./gulpjs/gulp/blob/master/docs/recipes/running-tasks-in-series.md.
This issue faced me because of the version of gulp I installed using npm i gulp
to solve this quickly, downgrade to that gulp version you used before 2 years and everything will work fine.
本文标签: javascriptAssertionError ERRASSERTION Task function must be specifiedStack Overflow
版权声明:本文标题:javascript - AssertionError [ERR_ASSERTION]: Task function must be specified - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745237793a2649139.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论