Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gulp ruby-sass and autoprefixer do not get along

I have a styles task in my gulpfile:

gulp.task('styles', function () {
  var sass = require('gulp-ruby-sass');
  var autoprefixer = require('gulp-autoprefixer');
    return gulp.src('app/styles/main.scss')
    .pipe(sass({sourcemap: true, sourcemapPath: '../scss'}))
    .on('error', function (err) { console.log(err.message); })
    .pipe(autoprefixer({
        browsers: ['last 2 versions'],
        cascade: false
    }))
    .pipe(gulp.dest('.tmp/styles'));
});

which generates this in the console:

[14:25:21] Starting 'styles'...
[14:25:21] gulp-ruby-sass: stderr: DEPRECATION WARNING: Passing --sourcemap without a value is    deprecated.
Sourcemaps are now generated by default, so this flag has no effect.
[14:25:21] gulp-ruby-sass: directory
[14:25:25] gulp-ruby-sass: write main.css
  write main.css.map

  events.js:72
    throw er; // Unhandled 'error' event
          ^
  Error: /Users/stevelombardi/Documents/command-central/ccgulp/main.css.map:3:3: Unknown word

IF I comment out the pipe to autoprefixer, no errors, everything compiles. What's the deal here?

Note, I also cannot seem to disable the writing of a sourcemap. I tried all the other settings from the repo page for grunt-ruby-sass and none work.

I can live without autoprefixer, but would love to get it working...

like image 529
Steve Avatar asked Nov 21 '14 19:11

Steve


1 Answers

The issue seems to happen related to the main.css.map, even if you didn't want one, using [email protected] at the time I am writing this.

I've come across two different solutions so far:

1) If you don't need sourcemaps:

gulp.task('styles', function() {
    gulp.src('app/styles/main.scss')
        .pipe(sass({
            "sourcemap=none": true // hack to allow auto-prefixer to work
        }))
        .pipe(prefix("last 2 versions"))
        .pipe(gulp.dest('css'));
});

This is what I have used as I recently encountered this issue.

2) If you do need sourcemaps:

Then you should try [email protected]

(relevent github issue)

like image 182
ryanwinchester Avatar answered Nov 08 '22 06:11

ryanwinchester