我刚刚开始使用grunt和cssmin来自动化 CSS 缩小过程。这在第一次工作正常,但后来文件内容被附加到缩小文件而不是覆盖它,并且它的重复文件大小变得越来越高!
我的 gruntfile.js 文件内容如下。
module.exports = function (grunt) {
grunt.initConfig({
// define source files and their destinations
cssmin: {
target: {
files: [{
src: ['assets/front/css/*.css', '!*.min.css'], // source files mask
dest: 'assets/front/css/', // destination folder
expand: true, // allow dynamic building
flatten: true, // remove all unnecessary nesting
ext: '.min.css' // replace .css to .min.css
}],
}
},
watch: {
css: { files: 'assets/front/css/*.css', tasks: [ 'cssmin' ] },
}
});
// load plugins
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-cssmin');
// register at least this one task
grunt.registerTask('default', [ 'cssmin', 'watch' ]);
};
请指教,我在哪里犯错了。