简体   繁体   English

Gulp-ruby-sass错误:

[英]Gulp-ruby-sass Error :

The gulp plugin gulp-ruby-sass doesn't work when compiling sass files . 编译sass文件时,gulp插件gulp-ruby-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)

This is a tricky one. 这是一个棘手的问题。 Looks like you're using generator-gulp-angular and selected ruby-sass . 看起来你正在使用generator-gulp-angular和选择的ruby-sass Unfortunately, the API of gulp-ruby-sass has changed in September (with their 2.0.0 release) and the generator wasn't updated since. 不幸的是, gulp-ruby-sass的API在9月份已经发生了变化(发布了2.0.0版本),而且自那时起生成器没有更新。 In a nutshell: the new API needs the source files passed into the stream factory method .pipe($.rubySass([**SOURCE FILES HERE**], sassOptions)).on('error', conf.errorHandler('RubySass')) which is basically not possible when combining the build chain with other plugins like inject or wiredep . 简而言之:新API需要传递到流工厂方法的源文件.pipe($.rubySass([**SOURCE FILES HERE**], sassOptions)).on('error', conf.errorHandler('RubySass'))当将构建链与其他插件(如injectwiredep组合时,这基本上是不可能的。 My recommendation is to use node-sass instead - if you have no absolute need for ruby-sass of course. 我的建议是使用node-sass - 如果你当然没有绝对需要ruby-sass

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM