简体   繁体   中英

Gulp not watching all tasks

I trying to compile my SASS to CSS but my gulp watch only on first task - where is bad?
gulpfile.js

var gulp = require('gulp');
var sass = require('gulp-sass');


gulp.task('styles', function() {
    gulp.src('sass/*.scss')
        .pipe(sass().on('error', sass.logError))
        .pipe(gulp.dest('./css/'));
});

gulp.task('bootstrap', function() {
    gulp.src('sass/bootstrap/bootstrap.scss')
        .pipe(sass().on('error', sass.logError))
        .pipe(gulp.dest('./plugins/bootstrap/css/'));
});

gulp.task('default',function() {
    gulp.watch('sass/*.scss',['styles']);
    gulp.watch('sass/bootstrap/*.scss',['bootstrap']);
});

Structure of my files:

assets
-- css/
---- style.css
-- node_modules/
---- (files from node)
-- sass/
---- bootstrap/
------- (parts of bootstrap)
---- bootstrap.scss
---- style.scss
-- gulpfile.js
-- package.json

I want compile:
assets/sass/style.scss -> assets/css/style.css
assets/sass/bootstrap.scss -> assets/plugins/bootstrap/css/bootstrap.min.css

Have you tried changing your default to following?

gulp.task('styleswatch', function() {
   gulp.watch('sass/*.scss',['styles']);
}
gulp.task('bootstrapwatch', function() {
   gulp.watch('sass/*.scss',['bootstrap']);
}
gulp.task('default',['styleswatch','bootstrapwatch']);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM