gulp plugin gulp-ruby-sass not compiling

2020-07-10 12:01发布

Gulp plugin gulp-ruby-sass(https://github.com/sindresorhus/gulp-ruby-sass) giving not compiling, the error message in terminal coming like this

3条回答
霸刀☆藐视天下
2楼-- · 2020-07-10 12:18

The official gulp-ruby-sass documentation says it should be done like this:

var gulp = require('gulp');
var sass = require('gulp-ruby-sass');    

gulp.task('sass', function () {
  return sass('source/file.scss')
    .on('error', sass.logError)
    .pipe(gulp.dest('result'));
});
查看更多
欢心
3楼-- · 2020-07-10 12:25

The gulp-ruby-sass syntax has been changed:

instead of:                          it is now:

gulp.task('styles', function (){     gulp.task('styles', function (){
    gulp.src('sass/app.scss')            return 
        .pipe(sass())                        sass('sass/app.scss')
        .pipe(gulp.dest('css/')              .pipe(gulp.dest('css/')
    ;                                    ;
});                                  }); 

Please check it out and mark your problem as solved.

查看更多
\"骚年 ilove
4楼-- · 2020-07-10 12:28

Install libsass because it runs much faster than ruby sass , it works with node

npm install gulp-sass --save-dev`

Install gulp load plugins because it does so much and loads plugins from your json and you dont need to declare in your gulpfile (carefull how many you use because if you load too many it hinders performance)

npm install --save-dev gulp-load-plugins

 var gulp = require('gulp'),
      $ = require('gulp-load-plugins')({
        pattern: ['gulp-*', 'gulp.*'],
        replaceString: /\bgulp[\-.]/,
        lazy: true,
        camelize: true
      });

gulp.task('libsass', function () {
      gulp.src('sass/app.scss')
          .pipe($.sass({errLogToConsole: true}))
          .pipe($.autoprefixer({
            browsers: ['last 2 versions'],
            cascade: false
           }))
          .pipe($.sourcemaps.write('app/css/map'))
          .pipe(gulp.dest('app/css'))
  });
查看更多
登录 后发表回答