Generate sourcemap for each partial

一个人想着一个人 提交于 2020-01-07 07:42:10

问题


I'm using the gulp-sass and would like for each partials he manages a sourcemap , I can do this using the less but did not see a way to do this with sass.

_partial.scss ( within it have to have a mapfile ).

_partial2.scss ( this also ).

回答1:


According the specification from sass-lang files starting with a _ are not compilled. See also: https://github.com/sass/node-sass/issues/215

So rename your partials with gulp-rename:

var sourcemaps = require('gulp-sourcemaps');
var gulp = require('gulp');
var sass = require('gulp-sass');
var rename = require("gulp-rename");

gulp.task('sass', function () {
    gulp.src('./scss/*.scss')
        .pipe(sourcemaps.init())
        .pipe(rename(function (path) {
        path.basename = path.basename.replace(/^_/,'');
        }))
        .pipe(sass())
        .pipe(sourcemaps.write())
        .pipe(gulp.dest('./css'));
});


来源:https://stackoverflow.com/questions/29635384/generate-sourcemap-for-each-partial

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!