gpt4 book ai didi

css - 使用 Grunt 和 grunt-contrib-cssmin 删除注释

转载 作者:太空宇宙 更新时间:2023-11-03 22:40:27 24 4
gpt4 key购买 nike

我尝试使用 Grunt 和 grunt-contrib-cssmin 删除所有 CSS 注释,CSS 文件已编译并缩小,它包含所有注释。

应使用以下行删除评论:keepSpecialComments: 0

module.exports = function(grunt) {
require('jit-grunt')(grunt);

grunt.initConfig({
less: {
development: {
options: {
compress: true,
yuicompress: true,
optimization: 2
},
files: {
"css/main.css": "less/bootstrap.less" // destination file and source file
}
}
},
watch: {
styles: {
files: ['less/**/*.less'], // which files to watch
tasks: ['less'],
options: {
nospawn: true
}
},
},
cssmin: {
options: {
keepSpecialComments: 0
}
}
});

grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.registerTask('default', ['less','cssmin', 'watch']);
};

最佳答案

根据作者提供的答案类型,grunt-decomment将是一个更通用的解决方案,它可以从任何文件中删除诸如 ///**/ 之类的注释。

关于css - 使用 Grunt 和 grunt-contrib-cssmin 删除注释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32994523/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com