Gulp-ruby-sass Error :

Gulp-ruby-sass Error :

编译时gulp插件gulp-ruby-sass不工作sass文件。


    'use strict';

    var path = require('path');
    var gulp = require('gulp');
    var conf = require('./conf');

    var browserSync = require('browser-sync');

    var $ = require('gulp-load-plugins')();

    var wiredep = require('wiredep').stream;
    var _ = require('lodash');

    gulp.task('styles-reload', ['styles'], function() {
      return buildStyles()
        .pipe(browserSync.stream());
    });

    gulp.task('styles', function() {
      return buildStyles();
    });

    var buildStyles = function() {
      var sassOptions = {
        style: 'expanded'
      };

      var injectFiles = gulp.src([
        path.join(conf.paths.src, '/app/**/*.scss'),
        path.join('!' + conf.paths.src, '/app/index.scss')
      ], { read: false });

      var injectOptions = {
        transform: function(filePath) {
          filePath = filePath.replace(conf.paths.src + '/app/', '');
          return '@import "' + filePath + '";';
        },
        starttag: '// injector',
        endtag: '// endinjector',
        addRootSlash: false
      };

      var cssFilter = $.filter('**/*.css', { restore: true });

      return gulp.src([
        path.join(conf.paths.src, '/app/index.scss')
      ])
        .pipe($.inject(injectFiles, injectOptions))
        .pipe(wiredep(_.extend({}, conf.wiredep)))
        .pipe($.rubySass(sassOptions)).on('error', conf.errorHandler('RubySass'))
        .pipe(cssFilter)
        .pipe($.sourcemaps.init({ loadMaps: true }))
        .pipe($.autoprefixer()).on('error', conf.errorHandler('Autoprefixer'))
        .pipe($.sourcemaps.write())
        .pipe(cssFilter.restore)
        .pipe(gulp.dest(path.join(conf.paths.tmp, '/serve/app/')));
    };


TypeError: glob pattern string required
    at new Minimatch (/home/john/sac_srvs/new_srvs/sachin/node_modules/gulp-ruby-sass/node_modules/glob/node_modules/minimatch/minimatch.js:108:11)
    at setopts (/home/john/sac_srvs/new_srvs/sachin/node_modules/gulp-ruby-sass/node_modules/glob/common.js:112:20)
    at new GlobSync (/home/john/sac_srvs/new_srvs/sachin/node_modules/gulp-ruby-sass/node_modules/glob/sync.js:38:3)
    at Function.globSync [as sync] (/home/john/sac_srvs/new_srvs/sachin/node_modules/gulp-ruby-sass/node_modules/glob/sync.js:24:10)
    at /home/john/sac_srvs/new_srvs/sachin/node_modules/gulp-ruby-sass/index.js:68:21
    at Array.forEach (native)
    at Object.gulpRubySass (/home/john/sac_srvs/new_srvs/sachin/node_modules/gulp-ruby-sass/index.js:67:10)
    at buildStyles (/home/john/sac_srvs/new_srvs/sachin/gulp/styles.js:50:13)
    at Gulp.sassOptions.style (/home/john/sac_srvs/new_srvs/sachin/gulp/styles.js:20:10)
    at module.exports (/home/john/sac_srvs/new_srvs/sachin/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:34:7)
    at Gulp.Orchestrator._runTask (/home/john/sac_srvs/new_srvs/sachin/node_modules/gulp/node_modules/orchestrator/index.js:273:3)
    at Gulp.Orchestrator._runStep (/home/john/sac_srvs/new_srvs/sachin/node_modules/gulp/node_modules/orchestrator/index.js:214:10)
    at Gulp.Orchestrator.start (/home/john/sac_srvs/new_srvs/sachin/node_modules/gulp/node_modules/orchestrator/index.js:134:8)
    at /usr/local/lib/node_modules/gulp/bin/gulp.js:129:20
    at process._tickCallback (node.js:415:13)
    at Function.Module.runMain (module.js:499:11)

这是一个棘手的问题。看起来您正在使用 generator-gulp-angular 并选择了 ruby-sass。不幸的是,gulp-ruby-sass 的 API 在 9 月发生了变化(发布了 2.0.0),此后生成器没有更新。简而言之:新的 API 需要将源文件传递给流工厂方法 .pipe($.rubySass([**SOURCE FILES HERE**], sassOptions)).on('error', conf.errorHandler('RubySass')) 当将构建链与 injectwiredep 等其他插件组合时,这基本上是不可能的。 我的建议是改用 node-sass - 如果您当然没有绝对需要 ruby-sass