问题: 我正在使用 gulp-sass 并且想定义一个 load_path 这样我就不必有很长的 @import 规则 voor bower 依赖项,例如
@import "normalize"
代替
@import "../../../../../bower_components/bootstrap-sass/assets/stylesheets/bootstrap/normalize"
在使用使用 LibSass 引擎处理 sass 文件的 gulp-sass 时,实现此目标的最佳方法是什么?
最佳答案
在我自己努力解决这个问题之后,我在 gulp-sass 中找到了一个选项:
sass({includePaths: ['./bower_components/bootstrap-sass/assets/stylesheets']})
例子:
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'));
});
关于css - gulp-sass 解决 load_path 支持?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32265121/