0
votes

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

1
I would think that just adding return statements to your 'styles" and 'bootstrap' tasks might fix this. Plus your bootstrap.scss will be in your sass/*.scss stream which it doesn't appear you want.Mark

1 Answers

0
votes

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']);