gulp 与 gulp-ruby-sass:错误:../style.css.map:3:1:未知单词

gulp with gulp-ruby-sass: Error: ../style.css.map:3:1: Unknown word(gulp 与 gulp-ruby-sass:错误:../style.css.map:3:1:未知单词)
本文介绍了gulp 与 gulp-ruby-sass:错误:../style.css.map:3:1:未知单词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用基本的 gulp/express build watch 时遇到一个奇怪的错误.

Getting a strange error using a basic gulp/express build watch.

目录布局

 project/
   - sass/
      - style.scss
   - gulpfile.js
   - index.html

Gulpfile.js

var gulp         = require('gulp'),
    sass         = require('gulp-ruby-sass'),
    autoprefixer = require('gulp-autoprefixer'),
    minifycss    = require('gulp-minify-css'),
    rename       = require('gulp-rename');

gulp.task('express', function() {
  var express = require('express');
  var app = express();
  app.use(require('connect-livereload')({port: 4002}));
  app.use(express.static(__dirname));
  app.listen(4000);
});

var tinylr;
gulp.task('livereload', function() {
  tinylr = require('tiny-lr')();
  tinylr.listen(4002);
});

function notifyLiveReload(event) {
  var fileName = require('path').relative(__dirname, event.path);

  tinylr.changed({
    body: {
      files: [fileName]
    }
  });
}

gulp.task('styles', function() {
    return gulp.src('sass/*.scss')
      .pipe(sass({ style: 'expanded', sourcemap: false }))
      .pipe(autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1'))
      .pipe(gulp.dest('css'))
      .pipe(rename({suffix: '.min'}))
      .pipe(minifycss())
      .pipe(gulp.dest('css'));
});

gulp.task('watch', function() {
  gulp.watch('sass/*.scss', ['styles']);
  gulp.watch('*.html', notifyLiveReload);
  gulp.watch('css/*.css', notifyLiveReload);
});

gulp.task('default', ['styles', 'express', 'livereload', 'watch'], function() {

});

Style.scss

body { position: relative; }

快速服务器/livereload 工作正常,但是当它尝试编译样式表时出现此错误(即使使用 sourcemap: false)

The express server/livereload works fine, but when it tries to compile the stylesheet I'm getting this error (even with sourcemap: false)

gulp-ruby-sass: write style.css.map

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: <LOCAL_PATH_HERE>/style.css.map:3:1: Unknown word

推荐答案

现在禁用源映射是个谜.你必须这样做

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

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

来源

这篇关于gulp 与 gulp-ruby-sass:错误:../style.css.map:3:1:未知单词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Update another component when Formik form changes(当Formik表单更改时更新另一个组件)
Formik validation isSubmitting / isValidating not getting set to true(Formik验证正在提交/isValiating未设置为True)
React Validation Max Range Using Formik(使用Formik的Reaction验证最大范围)
Validation using Yup to check string or number length(使用YUP检查字符串或数字长度的验证)
Updating initialValues prop on Formik Form does not update input value(更新Formik表单上的初始值属性不会更新输入值)
password validation with yup and formik(使用YUP和Formick进行密码验证)