GLUP V4.0.0'gulp start'不是一个功能 [英] Glup V4.0.0 'gulp start' is not a function
本文介绍了GLUP V4.0.0'gulp start'不是一个功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在gulpfile.js下面有这个.当我使用"gulp start"运行应用程序时,它表明启动不是一个功能. 我正在使用V4.0.0的Glup-cli版本
I have this below gulpfile.js. When i run the app using 'gulp start' then it is showing start is not a function. Glup-cli version i'm using V4.0.0
const gulp = require('gulp');
const concat = require('gulp-concat');
const browserSync = require('browser-sync').create();
const scripts = require('./scripts');
const styles = require('./styles');
// Some pointless comments for our project.
var devMode = false;
gulp.task('css', function() {
gulp.src(styles)
.pipe(concat('main.css'))
.pipe(gulp.dest('dist/css'))
.pipe(browserSync.reload({
stream: true
}));
});
gulp.task('js', function() {
gulp.src(scripts)
.pipe(concat('scripts.js'))
.pipe(gulp.dest('./dist/js'))
.pipe(browserSync.reload({
stream: true
}));
});
gulp.task('html', function() {
return gulp.src('./src/templates/**/*.html')
.pipe(gulp.dest('./dist/'))
.pipe(browserSync.reload({
stream: true
}));
});
gulp.task('build', function() {
gulp.start(['css', 'js', 'html'])
});
gulp.task('browser-sync', function() {
browserSync.init(null, {
open: false,
server: {
baseDir: 'dist',
}
});
});
gulp.task('start', function() {
devMode = true;
gulp.start(['build', 'browser-sync']);
gulp.watch(['./src/css/**/*.css'], ['css']);
gulp.watch(['./src/js/**/*.js'], ['js']);
gulp.watch(['./src/templates/**/*.html'], ['html']);
});
推荐答案
gulp.start
在v4中已被弃用.根据您的需求,您可以改用gulp.series
或gulp.parallel
.
gulp.start
has been deprecated in v4. Depending on your needs, you can use gulp.series
or gulp.parallel
instead.
- gulp.task('start', function() {
- devMode = true;
- gulp.start(['build', 'browser-sync']);
+ gulp.task('start', gulp.series('build', 'browser-sync'), function(done) {
+ devMode = true;
gulp.watch(['./src/css/**/*.css'], ['css']);
gulp.watch(['./src/js/**/*.js'], ['js']);
gulp.watch(['./src/templates/**/*.html'], ['html']);
});
这个问题可能是这个问题的重复,但是既然那个问题还没有被接受的答案,我就回覆马克的答案.
This question is probably a duplicated of this one, but since that question hasn't got an accepted answer I'll just echo Mark's answer.
这篇关于GLUP V4.0.0'gulp start'不是一个功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文