gulp在多次处理后保持理智的源地图

时间:2014-11-06 03:41:24

标签: sass

我已经优化了我的css编译速度,并且在一项任务中基本上将3个操作排在一起。它运作良好,但现在我有点卡住生成适当的sourceMaps。

1 个答案:

答案 0 :(得分:1)

我简化了你的样本,但你可以尝试类似于这个的解决方案:

var gulp = require('gulp'),
    filter = require('gulp-filter'),
    less = require('gulp-less'),
    concat = require('gulp-concat'),
    sourcemaps = require('gulp-sourcemaps');

gulp.task('default', function(){

    var lessFilter = filter(['**/*.less']);
    var cssFilter = filter(['**/*.css']);

    return gulp.src('src/**/*')
        .pipe(sourcemaps.init())
        .pipe(lessFilter)
        .pipe(less())
        .pipe(lessFilter.restore())
        .pipe(cssFilter) // Needed only in case the src folder contains files that are not compiled to css at this stage of the pipeline
        .pipe(concat('./final.css'))
        .pipe(sourcemaps.write())
        .pipe(gulp.dest('dest'));
});