Gulp 我怎样才能自动运行所有的吞咽任务?

Gulp 我怎样才能自动运行所有的吞咽任务?,gulp,browser-sync,Gulp,Browser Sync,我来找你帮忙。 我正在使用gulp和浏览器同步来自动化我的任务:编译sass,在每次更改时重新启动开发服务器,以及检查浏览器中的更改。我只是想快点。问题是,当我运行gulp(我也使用gulp nodemon)时,它只运行nodemon,但浏览器同步不运行,其他任务也不运行。如果我单独运行每个任务,它们都可以工作,但是默认情况下,使用gulp时,它们一起运行,就不工作了。如果你想帮助我,我将永远感激你 这是我的密码 const gulp = require('gulp'), sas

我来找你帮忙。 我正在使用gulp和浏览器同步来自动化我的任务:编译sass,在每次更改时重新启动开发服务器,以及检查浏览器中的更改。我只是想快点。问题是,当我运行gulp(我也使用gulp nodemon)时,它只运行nodemon,但浏览器同步不运行,其他任务也不运行。如果我单独运行每个任务,它们都可以工作,但是默认情况下,使用gulp时,它们一起运行,就不工作了。如果你想帮助我,我将永远感激你

这是我的密码

    const gulp = require('gulp'),
    sass = require('gulp-sass'),
    autoprefixer = require('gulp-autoprefixer'),
    browserSync = require('browser-sync').create(),
    nodemon = require('gulp-nodemon'),
    watch = require('gulp-watch');

gulp.task('scss', () => {

    let stream = gulp
        .src('./src/scss/*/*.scss')
        .pipe(sass({outputStyle: 'expanded',}))
        .pipe(autoprefixer({ versions: 'last 2 browsers', }))
        .pipe(gulp.dest('./src/public/css'))
        .pipe(browserSync.stream());

    return stream;
});

gulp.task('nodemon', cb => {
    let started = false;

    return nodemon({
        script: './src/index.js',
        ext: 'ejs js',
        ignore: ['gulpfile.js'],
    }).on('start', () => {
        if (!started) {
            cb();
            started = true;
        }
    });
});

gulp.task('browser-sync', gulp.series('nodemon'), () => {
    browserSync.init({
        proxy: 'http://localhost:3000',
        open: false,
        files: ['public/**/*.js'],
        browser: 'google chrome',
        port: 3000,
    });
});

gulp.task('default', gulp.series('browser-sync'), () => {
    gulp.watch('./src/views/*/*.ejs').on('change', browserSync.reload());
    gulp.watch('./src/public/*/*.js').on('change', browserSync.reload());
    gulp.watch('./src/public/css/*/*.css').on('change', browserSync.stream());
    gulp.watch('./src/scss/*/*.scss', gulp.series('scss'));
});

这有三个理由:

gulp.task('browser-sync',gulp.series('nodemon'),()=>{

在GulpV4+中,您只能有两个参数,因此将其更改为

gulp.task('browser-sync',gulp.series('nodemon',()=>{

同样的

gulp.task('default',gulp.series('browser-sync',()=>{

  • 在这些函数的末尾也会有一个接近的paren
    ,比如
    };