6

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

Error: must provide pattern

Here is the gulpfile.js details

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

    gulp.task('styles', function (argument) {
        gulp.src('sass/app.scss')
            .pipe(sass())
            .pipe(gulp.dest('css/'));
    });
Mo.
  • 26,306
  • 36
  • 159
  • 225

3 Answers3

17

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.

Guenther
  • 403
  • 2
  • 16
6

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'));
});
ngstschr
  • 2,119
  • 2
  • 22
  • 38
  • I have already got that solution but still I am afraid why the code `gulp.src('sass/app.scss')` doesn't work. because most of the tutorials are working with this code :( example:https://www.youtube.com/watch?v=cg7lwX0u-U0 , https://www.youtube.com/watch?v=NkomAUQxYr8 – Mo. Oct 12 '15 at 14:33
  • The sass function works in a different way. It expects a path 'pattern' argument. That is why you get the error. Why isn't the example code working for you? What is it you want to achieve that isn't working out for you with the official example? – ngstschr Oct 12 '15 at 14:54
2

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