类型错误:需要全局模式字符串

2024-01-04

我正在尝试编译sass using 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,所以如果我犯了一个小错误,请原谅。


看着docs https://github.com/sindresorhus/gulp-ruby-sass,看来你不应该通过管道进入gulp-ruby-sass,而是直接这样调用它:

gulp.task('styles', function () {
    return sass(paths.sassSrcPath, {
            style: 'compressed',
            loadPath: [paths.sassImportsPath]
        })
        .pipe(gulp.dest(paths.sassDestPath));
});
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

类型错误:需要全局模式字符串 的相关文章