Gulp WATCH不监听新添加的.scss部分中的任何更改

时间:2018-11-27 22:04:26

标签: sass gulp reload watch partials

我对吞吃任务有疑问。 确切地说,它不适用于我添加的.scss分部。仅当我再次运行任务时,它才能开始工作。

有我的gulpfile:

const gulp = require('gulp'),
  plugins = require('gulp-load-plugins')({
    lazy: true,
  }),
  browserSync = require('browser-sync'),
  webpack = require('webpack'),
  webpackStream = require('webpack-stream'),
  webpackConfig = require('./webpack.config.js');


gulp.task('css', function () {
  return gulp.src('src/sass/main.scss')
    .pipe(plugins.plumber())
    .pipe(plugins.sass({
      includePaths: ['./node_modules'],
    }))
    .on('error', plugins.sass.logError)
    .pipe(plugins.autoprefixer('last 4 versions'))
    .pipe(plugins.combineMq({
      beautify: false
    }))
    .pipe(gulp.dest('src/assets/css'))
    .pipe(browserSync.stream());
});

gulp.task('js', () => {
  gulp.src('src/assets/js/main.js')
    .pipe(webpackStream(webpackConfig), webpack)
    .pipe(gulp.dest('js'));
});

gulp.task("server", function () {

  browserSync.init({
    proxy: "http://wp-boilerplate.test"
  });

});

gulp.task("watch", function () {

  gulp.watch('src/sass/**/*.scss', ["css"]);
  gulp.watch(["*.php", "src/assets/js/*.js"], browserSync.reload);

});

gulp.task("default", ["css", "server", "watch"]);

我读过其他文章,但找不到有效的解决方案。

如果有人可以帮助我,我将不胜感激。

0 个答案:

没有答案