我正在尝试生成源映射并缩小它,但它不起作用。
文件位置:test/test.less
输出:文件名 test/test.less
地图文件 test.css.map
压缩文件 test.min.css
当我在浏览器上加载该文件时,它不会被加载,但是当我加载 bootstrap.css.map 文件时,它会显示每个 css 或更少的文件。
var gulp = require( "gulp" ),
concat = require( "gulp-concat" ),
watch = require( "gulp-watch" ),
notify = require( "gulp-notify" ),
less = require( "gulp-less" ),
sourcemaps = require( "gulp-sourcemaps" );
var testCSSFile = "test/test.css";
var filePosition = "test";
gulp.task( "testCSS", function() {
gulp.src( testCSSFile )
.pipe( concat( "test.less" ) )
.pipe( sourcemaps.init() )
.pipe( less() )
.pipe( sourcemaps.write( ".") )
.pipe( gulp.dest(filePosition) )
.pipe( notify( "testCSS task completed." ) );
return gulp.src( testCSSFile )
.pipe( concat( "test.min.less" ) )
.pipe( less({
compress: true
}) )
.pipe( gulp.dest(filePosition) )
.pipe( notify( "testCSS task completed." ) );
});
gulp.task( "watch", function() {
gulp.watch( testCSSFile, [ "testCSS" ] );
});
gulp.task( "default", [
"testCSS",
"watch"
] );