我正在尝试使用sass
在我的配置中运行gulp-ruby-sass
任务,这是我得到的错误(我的配置和代码后面会出现错误):
[04:57:11] TypeError: undefined is not a function
at DestroyableTransform.Readable.pipe [as _pipe] (E:\Do\angular-jspm-todo\no
de_modules\gulp-autoprefixer\node_modules\through2\node_modules\readable-stream\
lib\_stream_readable.js:516:8)
at DestroyableTransform.pipe2 (E:\Do\angular-jspm-todo\node_modules\gulp-plu
mber\index.js:70:20)
at Gulp.<anonymous> (E:\Do\angular-jspm-todo\gulp\tasks\sass.js:15:8)
at module.exports (E:\Do\angular-jspm-todo\node_modules\gulp\node_modules\or
chestrator\lib\runTask.js:34:7)
at Gulp.Orchestrator._runTask (E:\Do\angular-jspm-todo\node_modules\gulp\nod
e_modules\orchestrator\index.js:273:3)
at Gulp.Orchestrator._runStep (E:\Do\angular-jspm-todo\node_modules\gulp\nod
e_modules\orchestrator\index.js:214:10)
at E:\Do\angular-jspm-todo\node_modules\gulp\node_modules\orchestrator\index
.js:279:18
at finish (E:\Do\angular-jspm-todo\node_modules\gulp\node_modules\orchestrat
or\lib\runTask.js:21:8)
at module.exports (E:\Do\angular-jspm-todo\node_modules\gulp\node_modules\or
chestrator\lib\runTask.js:60:3)
at Gulp.Orchestrator._runTask (E:\Do\angular-jspm-todo\node_modules\gulp\nod
e_modules\orchestrator\index.js:273:3)
[04:57:11] gulp-ruby-sass stderr: OptionParser::InvalidOption: invalid option: -
-sourcemap-path=app/css
Use --trace for backtrace.
E:\Do\angular-jspm-todo\node_modules\gulp-autoprefixer\node_modules\through2\nod
e_modules\readable-stream\lib\_stream_readable.js:523
dest.end();
^
TypeError: undefined is not a function
at DestroyableTransform.onend (E:\Do\angular-jspm-todo\node_modules\gulp-aut
oprefixer\node_modules\through2\node_modules\readable-stream\lib\_stream_readabl
e.js:523:10)
at DestroyableTransform.g (events.js:199:16)
at DestroyableTransform.emit (events.js:129:20)
at E:\Do\angular-jspm-todo\node_modules\gulp-autoprefixer\node_modules\throu
gh2\node_modules\readable-stream\lib\_stream_readable.js:965:16
at process._tickCallback (node.js:355:11)
我对sass任务的配置如下所示:
sass: {
src: app + '/scss/**/*.{sass,scss}',
dest: app + '/css',
options: {
noCache: true,
compass: false,
sourcemap: true,
sourcemapPath: app+'/css'
}
},
autoprefixer: {
browsers: [
'last 2 versions',
'safari 5',
'ie 8',
'ie 9',
'opera 12.1',
'ios 6',
'android 4'
],
cascade: true
},
scsslint: {
src: [
app + '/scss/**/*.{sass,scss}',
]
}
sass
任务在这里:
gulp.task('sass',function(){
return sass(config.sass.src,config.sass.options)
.pipe(plumber({errorHandler:notify.onError('<%= error.message %>')}))
.pipe(sourcemaps.init())
.pipe(autoprefixer(config.autoprefixer))
.pipe(filter)
.pipe(sourcemaps.write('.',{includeContent:false}))
.pipe(filter.restore())
.pipe(gulp.dest(config.sass.dest));
});
这是我的scsslint
任务:
var gulp = require('gulp');
var scsslint = require('gulp-scss-lint');
var config = require('../config').scsslint;
gulp.task('scsslint',function(){
return gulp.src(config.src)
.pipe(scsslint(config.options))
});
我为browser-sync
和watch
任务执行了这些操作:
gulp.task('serve',['jshint','scsslint','sass'],function(){
browserSync(config);
});
gulp.task(&#39;观看&#39; [&#39;服务&#39],函数(){ gulp.watch(config.jshint,[&#39; jshint&#39;]); gulp.watch(config.sass,[&#39; scsslint&#39;&#39; SASS&#39;]); });
答案 0 :(得分:0)
我可以从堆栈跟踪中看到两个问题:
1 - 我认为您在执行var filter = gulpFilter(['*.css', '!*.map']);
pipe(filter)
2 - 如果您在此处阅读了gulp-ruby-sass的文档,则没有sourcemapPath选项:https://github.com/sindresorhus/gulp-ruby-sass
答案 1 :(得分:0)
您正在为您的来源使用glob。来自gulp-ruby-sass README:
gulp-ruby-sass还不支持globs,只支持单个文件或目录。就像萨斯一样。
要修复,请将配置更改为:
src: app + '/scss'