TypeError:需要glob模式字符串

时间:2015-10-06 10:13:40

标签: gulp gulp-ruby-sass

我尝试使用sass汇编gulp-ruby-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

我是Gulp的新手,我还没有使用过Grunt,如果我犯了一个小错误,请原谅我。

1 个答案:

答案 0 :(得分:18)

查看docs,您似乎不应该管道gulp-ruby-sass,而是直接调用它:

gulp.task('styles', function () {
    return sass(paths.sassSrcPath, {
            style: 'compressed',
            loadPath: [paths.sassImportsPath]
        })
        .pipe(gulp.dest(paths.sassDestPath));
});