When running the grunt.js task cssMin https://github.com/gruntjs/grunt-contrib-cssmin
Svg css properties are being removed.
For example:
.testClass {
r: 4;
width: 3px;
margin-left: 18px !important;
}
Gets converted to
.testClass {
width: 3px;
margin-left: 18px !important;
}
How can I prevent this from happening?
grunt-contrib-cssminusesclean-cssinternally, as stated in options, and any native (clean-css) options "are passed to clean-css".clean-cssgroups optimizations into levels, for convenience. There are two options controlling removal of rules, both found under level 2:This should do it:
Starting with clean-css 4.2.0 a "comment" block method for skipping fragments entirely will be available:
Note
4.2has not been released yet.After a bit of testing, none of the above seems to actually work, although they "should", according to documentation.
The only alternative I have is replacing
grunt-contrib-cssminwithgrunt-postcss cssnano(which is what I use with grunt for minification):In practice, I use more
postcssaddons.Here's a practical example with
autoprefixer,pixrem,postcss-flexboxandcssnano:I purposefully registered a task that only runs the
postcssplugin:Don't forget you need to install each addon for usage with
postcss. For the above, you'd need:... and, most likely, you'll want to change
filesto match whatever you have.This time around, I tested. The
rproperty makes it into the minified file: