grunt-contrib-less
包提供选项compress
,该选项应允许管理目标CSS文件的uglifying / minifying / compression。它是boolean
,默认值为false
。
由于任何原因,它对我不起作用 - 无论我将参数设置为什么,输出CSS文件都会被压缩。何以使其正常工作?
Gruntfile.js
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
less: {
development: {
options: {
paths: ["public/css"],
compress: false
},
files: {
"public/css/style.css": "public/css/style.less"
}
},
production: {
options: {
paths: ["public/css"],
compress: false,
plugins: [
new (require('less-plugin-autoprefix'))({browsers: ["last 2 versions"]}),
new (require('less-plugin-clean-css'))([])
],
modifyVars: {
}
},
files: {
"public/css/style.css": "public/css/style.less"
}
}
}
});
// Load the plugin that provides the "less" task.
grunt.loadNpmTasks('grunt-contrib-less');
// Default task(s).
grunt.registerTask('default', ['less']);
};
CLI
$ grunt --version
grunt-cli v0.1.13
grunt v0.4.5
$ grunt
Running "less:development" (less) task
File public/css/style.css created
Running "less:production" (less) task
File public/css/style.css created
Done, without errors.
答案 0 :(得分:1)
这是我的坏...由于less-plugin-clean-css
的使用,CSS文件已被压缩。我删除后,可以通过compress
参数再次管理压缩。