Answer the question
In order to leave comments, you need to log in
How to run a task in Gulp only after other tasks have completed?
Hello, I have the following gulpfile.js:
var gulp = require('gulp'),
sass = require('gulp-sass'),
concatcss = require('gulp-concat'),
clean = require('gulp-clean'),
plumber = require('gulp-plumber');
// Собирает все scss файлы в директории blocks и склеивает их в один
gulp.task('blocks', function() {
return gulp.src('app/scss/blocks/**/*.scss')
.pipe(plumber())
.pipe(concatcss("_blocks.scss"))
.pipe(gulp.dest('app/scss/build/'));
});
// Запускает генерацию финального css файла из имеющихся scss
gulp.task('sass', function() {
return gulp.src('app/scss/main.scss')
.pipe(plumber())
.pipe(sass())
.pipe(gulp.dest('app/css'))
});
// Очищает результирующий файл сборки для последующей записи в него
gulp.task('clean', function () {
return gulp.src('app/scss/build/_blocks.scss', {read: false})
.pipe(clean());
});
gulp.task('watch', function() {
gulp.watch(['app/scss/**/*.scss'], ['clean']);
gulp.watch(['app/scss/blocks/**/*.scss'], ['blocks']);
gulp.watch(['app/scss/**/*.scss'], ['sass']);
});
@import 'vendors/normalize';
@import 'utils/variables';
@import 'base/fonts';
@import 'utils/placeholders';
@import 'build/blocks';
@import 'base/media';
Error in plugin 'gulp-sass'
Message:
app\scss\main.scss
Error: File to import not found or unreadable: build/blocks.
Parent style sheet: C:/Users/kalashnikov/Desktop/layout/relaxlux/app/scss/main.scss
on line 5 of app/scss/main.scss
Answer the question
In order to leave comments, you need to log in
gulp.task('watch', function() {
gulp.watch(['app/scss/**/*.scss'], ['clean','blocks','sass']);
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question