gulp with gulp-ruby-sass: Error: ../style.css.map:3:1: Unknown word(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:未知单词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:gulp 与 gulp-ruby-sass:错误:../style.css.map:3:1:未知单词


基础教程推荐
- 角度Apollo设置WatchQuery结果为可用变量 2022-01-01
- 当用户滚动离开时如何暂停 youtube 嵌入 2022-01-01
- 有没有办法使用OpenLayers更改OpenStreetMap中某些要素 2022-09-06
- 在 JS 中获取客户端时区(不是 GMT 偏移量) 2022-01-01
- Karma-Jasmine:如何正确监视 Modal? 2022-01-01
- 悬停时滑动输入并停留几秒钟 2022-01-01
- 我什么时候应该在导入时使用方括号 2022-01-01
- 响应更改 div 大小保持纵横比 2022-01-01
- 在for循环中使用setTimeout 2022-01-01
- 动态更新多个选择框 2022-01-01