Gulp TypeError:需要全局模式字符串
我正在尝试使用Gulp TypeError:需要全局模式字符串,gulp,gulp-ruby-sass,Gulp,Gulp Ruby Sass,我正在尝试使用gulpruby-sass编译sass,但是我得到了TypeError:glob-pattern-string-required 这就是我的gulpfile.js的样子: var gulp = require('gulp'), sass = require('gulp-ruby-sass'); var paths = { sassSrcPath: ['Content/css/**/*.scss'], sassDestPath: ['build/css/']
gulpruby-sass
编译sass
,但是我得到了TypeError:glob-pattern-string-required
这就是我的gulpfile.js
的样子:
var gulp = require('gulp'),
sass = require('gulp-ruby-sass');
var paths = {
sassSrcPath: ['Content/css/**/*.scss'],
sassDestPath: ['build/css/'],
sassImportsPath: ['Content/styleguide/']
};
// Styles Task
gulp.task('styles', function () {
gulp.src(paths.sassSrcPath)
.pipe(sass({
style: 'compressed',
loadPath: [paths.sassImportsPath]
}))
.pipe(gulp.dest(paths.sassDestPath));
});
// Watch Task
gulp.task('watch', function () {
gulp.watch(paths.sassSrcPath, ['styles']);
});
gulp.task('default', ['styles', 'watch']);
以下是我的文件夹结构:
├── Content
│ ├── css
│ │ ├── partials
│ │ │ └─_icons.scss
│ │ ├── main.css.scss
│ │ └── styleguide.css.scss
│ └── styleguide
│ ├── css
│ │ └─ vendor
│ │ └─ // Bunch of other folders that contain .sass files
│ └── // Other .sass files
└── gulpfile.js
我刚开始吞咽,而且我也没有使用Grunt,所以如果我犯了一个小错误,请原谅。看一下,你似乎不应该通过管道吞咽ruby sass,而是直接这样称呼它:
gulp.task('styles', function () {
return sass(paths.sassSrcPath, {
style: 'compressed',
loadPath: [paths.sassImportsPath]
})
.pipe(gulp.dest(paths.sassDestPath));
});
非常感谢,我观看了视频教程,其中gulp ruby sass的使用方式与我的使用方式相同,因此我甚至没有查看官方文档。在我的情况下,即使直接运行sass,此sassDestPath:['build/css/']generate error“error:Invalid output folder”,因此我将其更改为'build/css/,这就解决了问题