grunt-contrib-cssmin

grunt-contrib-cssmin changes px to pc after minifying


I'm building an Angularjs app using yeoman angular generator, with libsass instead of compass, and it works great on local server.

But after build, some of my css properties changes from px to pc, and that's causes errors and styling issues.

Before Build [Not Minified]: background-position:-468px -11px

After Build [Minified]: background-position:-468px -11pc


Solution

  • We experienced the same issue on several of our projects, and tracked down a recent change in an internal dependency as the source of the issue.

    The grunt-contrib-cssmin module has an internal dependency on the clean-css module. Starting with version 3.4.1, the clean-css module turns on unit conversions by default, which then bubbles up into the behavior of grunt-contrib-cssmin. The clean-css module released version 3.4.2 which changes the default back to turn off unit conversions, based on community feedback. Version 0.14.0 of grunt-contrib-cssmin has been updated to use version 3.4.2 of clean-css.

    We were able to resolve this issue by updating to use version 0.14.0 of grunt-contrib-cssmin in our project's package.json file. Make sure to clear your node-modules folder or run 'npm update' to ensure it's actually getting the latest versions.