gulp with gulp-ruby-sass: Error: ../style.css.map:3:1: Unknown word

情到浓时终转凉″ 提交于 2019-11-30 02:13:05

Disabling sourcemaps is some kind of mystery right now. You have to do it like this

.pipe(sass({ "sourcemap=none": true }))

Source

Not entirely sure why this fixes it, but changing the autoprefixer pipe to:

.pipe(autoprefixer({
     browsers: ['last 2 versions'],
     cascade: false
}))

and putting it before the sass pipe (top) allows it to build succesfully.

I fixed this problem keeping the source maps and using gulp-filter:

var filter = require('gulp-filter')
var filterCSS = filter('**/*.css');

gulp.task('styles', function() {
    return gulp.src('sass/*.scss')
      .pipe(sass({ style: 'expanded', sourcemap: true }))

      // Filters only css files before auto prefixing
      .pipe(filterCSS)
      .pipe(autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1'))
      .pipe(filterCSS.restore())

      .pipe(gulp.dest('css'))
      .pipe(rename({suffix: '.min'}))
      .pipe(minifycss())
      .pipe(gulp.dest('css'));
});

I was having the same issue with the gulp-ruby-sass plugin. I found this blog post which explains that there are a couple of bugs in the gulp-ruby-sass plugin regarding source maps. They have both been closed a little over a week ago. If you upgrade to gulp-ruby-sass~1.0.0-alpha this should fix the issues your having with source maps.

If that doesn't work the article I linked to above shows how to use the gulp-sass plugin which which doesn't have the source map issue.

Try upgrading to gulp-ruby-sass 1.0.0-alpha. It uses gulp-sourcemaps and should avoid all iterations of this problem.

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