gulp plugin gulp-ruby-sass not compiling

末鹿安然 提交于 2019-12-04 05:41:06

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.

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'));
});

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'))
  });
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!