In my Gruntfile I'm using cssmin (grunt-contrib-cssmin) task. Something like:
cssmin: {
css : {
src: "dist/styles.css",
dest: "dist/styles.min.css"
}
}
The problem is: styles.css is generated with a concat task that concatenates lots of .css files. In some of files I have the same css selector (example: .panel a) Only the first one selector is kept bu the cssmin task, all others are removed. I guess it's a default behaviour of the task. Is there a way to keep duplicated selectors?
Grunt cssmin has a dependency on node.js module clean-css. I would recommend to use clean-css
API within Grunt with the options available https://github.com/jakubpawlowicz/clean-css#how-to-use-clean-css-api.
One of the parameters available is;
advanced - set to false to disable advanced optimizations - selector & property merging, reduction, etc.
You play with this option on http://refresh-sf.com/. If you go to tab 'clean-css' below the textarea, you could enable/disable advanced
to see it working.
Edit: Issued this at grunt-contrib-cssmin repo as an issue https://github.com/gruntjs/grunt-contrib-cssmin/issues/263
来源:https://stackoverflow.com/questions/26279789/avoid-grunt-cssmin-task-to-remove-duplicate-entries