我正在使用gulp任务编译bootstrap-sass:
gulp.task('build-bootstrap-sass', function () {
return gulp.src('styles/styles.sass')
.pipe(sourcemaps.init())
.pipe(sass({includePaths: ['node_modules/bootstrap-sass/assets/stylesheets/']}).on('error', sass.logError))
.pipe(rename({basename:'bootstrap'}))
.pipe(autoprefixer())
.pipe(minifyCss())
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('dist/' ));
});
但是这给了我以下错误:
[09:32:38] Using gulpfile d:\Code\Templates\App\gulpfile.js
[09:32:38] Starting 'build-bootstrap-sass'...
d:\Code\Templates\App\node_modules\gulp-minify-css\node_modules\clean-css\lib\text\escape-store.js:49
var index = this.restoreMatcher.exec(placeholder)[1];
^
TypeError: Cannot read property '1' of null
at EscapeStore.restore (d:\Code\Templates\App\node_modules\gulp-minify-css\node_modules\clean-css\lib\text\escape-store.js:49:52)
at UrlsProcessor.restore (d:\Code\Templates\App\node_modules\gulp-minify-css\node_modules\clean-css\lib\text\urls-processor.js:61:35)
at Object.restore (d:\Code\Templates\App\node_modules\gulp-minify-css\node_modules\clean-css\lib\clean.js:195:28)
at store (d:\Code\Templates\App\node_modules\gulp-minify-css\node_modules\clean-css\lib\stringifier\source-maps.js:12:21)
at value (d:\Code\Templates\App\node_modules\gulp-minify-css\node_modules\clean-css\lib\stringifier\helpers.js:102:5)
at property (d:\Code\Templates\App\node_modules\gulp-minify-css\node_modules\clean-css\lib\stringifier\helpers.js:91:5)
at body (d:\Code\Templates\App\node_modules\gulp-minify-css\node_modules\clean-css\lib\stringifier\helpers.js:77:5)
at all (d:\Code\Templates\App\node_modules\gulp-minify-css\node_modules\clean-css\lib\stringifier\helpers.js:140:9)
at stringify (d:\Code\Templates\App\node_modules\gulp-minify-css\node_modules\clean-css\lib\stringifier\source-maps.js:74:3)
at SelectorsOptimizer.process (d:\Code\Templates\App\node_modules\gulp-minify-css\node_modules\clean-css\lib\selectors\optimizer.js:20:10)
问题似乎是在我使用源图时;如果我删除它,任务就会通过。但我正在使用所有gulp依赖项的“最新”版本;并且gulp-minify-css changelog表明它支持源映射< 1.1.6。 当我使用sourcemaps而不缩小时,构建也会通过。
答案 0 :(得分:0)
gulp-sourcemaps
不支持gulp-minify-css
。
您可以在此处找到所有受支持的插件:https://github.com/floridoo/gulp-sourcemaps/wiki/Plugins-with-gulp-sourcemaps-support
您可以考虑使用gulp-cssnano来缩小css文件。