有没有人成功让Gulp-sass与基础4/5一起工作(最好用指南针?)
应用程序使用compass watch
成功地使用基础4,没有吞咽。但是我想开始使用gulp来简化我的sass / coffee / minification编译。
这是我的gulpfile.js
var gulp = require('gulp'),
util = require('gulp-util'),
sass = require('gulp-sass'),
coffee = require('gulp-coffee');
var paths = {
scripts: {
src: 'src/coffee/**/*.coffee',
dest: 'public/javascripts'
},
styles: {
src: 'src/sass/*.sass',
dest: 'public/stylesheets'
}
};
gulp.task('scripts', function() {
return gulp.src(paths.scripts.src)
.pipe(coffee())
.pipe(gulp.dest(paths.scripts.dest));
});
gulp.task('sass', function () {
return gulp.src(paths.styles.src)
.pipe(sass({errLogToConsole: true}))
.pipe(gulp.dest(paths.styles.dest));
});
gulp.task('watch', function () {
gulp.watch(paths.scripts.src, ['scripts']);
gulp.watch(paths.styles.src, ['sass']);
});
gulp.task('default', ['scripts', 'sass', 'watch']);
这对于咖啡脚本编译非常有用,但是在使用sass / compass时,在注释行中失败了。
[gulp] Using file path/gulpfile.js
[gulp] Working directory changed to path
[gulp] Running 'scripts'...
[gulp] Running 'sass'...
[gulp] Running 'watch'...
[gulp] Finished 'watch' in 15 ms
[gulp] [gulp-sass] source string:1: error: @import directive requires a url or quoted path
// Here is what's throwing me for a loop. I'm assuming that it has something to do with
// gulp-sass not utilizing the ruby gem's source files for zurb-foundation/compass
[gulp] Finished 'sass' in 115 ms
[gulp] Finished 'scripts' in 122 ms
[gulp] Running 'default'...
[gulp] Finished 'default' in 11 μs
有没有解决方法,或者我最好从4升级到5并在我的src / coffee中添加基础文件,因此它不必依赖于查看我的.rvm/../gems
文件夹??
答案 0 :(得分:6)
尝试gulp-compass而不是gulp-sass。
修改强>
首先让我为我糟糕的回答道歉。
我自己测试了gulp-compass,它起作用了。我不确定你的基金会设置,但我选择的是使用基础与指南针 Getting Started on SASS。
我的gulpfile.js的相关部分是:
var compass = require('gulp-compass');
var paths = {
styles: {
src: 'scss/*.scss',
dest: 'stylesheets'
}
};
gulp.task('sass', function () {
return gulp.src(paths.styles.src)
.pipe(compass({
config_file: './config.rb',
css: 'stylesheets',
sass: 'scss'
}))
.pipe(gulp.dest(paths.styles.dest));
});
上面的示例与您的目录结构不同。所以,你的gulpfile.js将是:
var compass = require('gulp-compass');
var paths = {
styles: {
src: 'src/sass/*.sass',
dest: 'public/stylesheets'
}
};
gulp.task('sass', function () {
return gulp.src(paths.styles.src)
.pipe(compass({
config_file: './config.rb',
css: 'stylesheets',
sass: 'sass'
}))
.pipe(gulp.dest(paths.styles.dest));
});
对于'compass()'的选项,“css”应该是'config.rb'中的'css_dir'和'sass_dir'中的'sass',如the README of gulp-compass中所述。
希望它对你有用。