gulp-sass work around for load_path support?

烂漫一生 提交于 2019-12-21 04:11:36

问题


Problem: I'm using gulp-sass and would like to define a load_path so that I don't have to have really long @import rules voor bower dependencies e.g.

@import "normalize"

instead of

@import "../../../../../bower_components/bootstrap-sass/assets/stylesheets/bootstrap/normalize"

What is the best way to i achieve this when using gulp-sass which uses the LibSass engine to process sass files?


回答1:


After struggling with this myself I found a option in gulp-sass :

sass({includePaths: ['./bower_components/bootstrap-sass/assets/stylesheets']})

Example:

var gulp = require('gulp'),
    sass = require('gulp-sass')
    notify = require("gulp-notify");

var config = {
    sassPath: './resources/sass',   // store the sass files I create
    bowerDir: './bower_components'
}

gulp.task('css', function() {
  return gulp.src(config.sassPath + '/style.scss')
    .pipe(sass({
        outputStyle: 'compressed',
        includePaths: [
            './resources/sass',
            config.bowerDir + '/bootstrap-sass/assets/stylesheets',
            config.bowerDir + '/font-awesome/scss']
        })
       .on("error", notify.onError(function (error) {
            return "Error: " + error.message;
        })))
    .pipe(gulp.dest('./public/css'));
});


来源:https://stackoverflow.com/questions/32265121/gulp-sass-work-around-for-load-path-support

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