0

我正在使用带有 PostCSS 的 Ruby sass。这是我的 gulp css 任务。

gulp.task('css', function () {
    var processors = [
    short,
    rucksack,
    postcssmodules
    ];
    return gulp.src('./css/src/*.scss')
        .pipe(postcss(processors, {syntax: scss}))
        .pipe(sass().on('error', sass.logError))
        .pipe(gulp.dest('./dest'));
});

我得到的错误

➜  website git:(master) ✗ gulp css
[09:52:08] Using gulpfile ~/my-projects/website/gulpfile.js
[09:52:08] Starting 'css'...
[09:52:08] 'css' errored after 12 ms
[09:52:08] Error: must provide pattern
    at new GlobSync (/Users/jitendravyas/my-projects/website/node_modules/glob/sync.js:29:11)
    at Function.globSync [as sync] (/Users/jitendravyas/my-projects/website/node_modules/glob/sync.js:24:10)
    at /Users/jitendravyas/my-projects/website/node_modules/gulp-ruby-sass/index.js:68:21
    at Array.forEach (native)
    at gulpRubySass (/Users/jitendravyas/my-projects/website/node_modules/gulp-ruby-sass/index.js:67:10)
    at /Users/jitendravyas/my-projects/website/gulpfile.js:48:15
    at taskWrapper (/Users/jitendravyas/my-projects/website/node_modules/undertaker/lib/set-task.js:13:15)
    at bound (domain.js:287:14)
    at runBound (domain.js:300:12)
    at asyncRunner (/Users/jitendravyas/my-projects/website/node_modules/async-done/index.js:36:18)
4

1 回答 1

2

You cannot use gulp-ruby-sass in a .pipe(). Read the docs:

Use gulp-ruby-sass instead of gulp.src to compile Sass files.

You'll have to use sass() before your postcss():

gulp.task('css', function() {
  var processors = [
    short,
    rucksack,
    postcssmodules
  ];
  return sass('./css/src/*.scss')
   .on('error', sass.logError)
   .pipe(postcss(processors))
   .pipe(gulp.dest('./dest'));
});
于 2016-05-21T07:25:04.197 回答