Why using grunt-contrib-cssmin changes my css while this should only minimize it

I use grunt-contrib-cssmin to minimize my css files. I think this tool (grunt-contrib-cssmin) is just a wrapper for clean-css. Everything is in order, except for the fact that this grunt plugin is making changes to my css. I tried using every parameter I could find in the clean-css repository, but nothing worked. Please help me, this thing is killing me!

Grant File:

module.exports = function (grunt) { 'use strict'; // Project configuration grunt.initConfig({ // Metadata pkg: grunt.file.readJSON('package.json'), cssmin: { options: { keepSpecialComments:'1', processImport: false, roundingPrecision: -1, shorthandCompacting: false, aggressiveMerging: false, advanced: false, }, minified_css_admin: { src: ['public/admin/css/style.default.css','public/admin/prettify/prettify.css','public/admin/css/bootstrap-fileupload.min.css','public/admin/css/developer.css'], dest: 'public/admin/css/minified-css-admin.min.css', }, }, }); // These plugins provide necessary tasks grunt.loadNpmTasks('grunt-contrib-cssmin'); // Default task grunt.registerTask('default', ['admin-default']); grunt.registerTask('admin-default', ['cssmin:minified_css_admin']); }; 

Before the thumbnail:

 .loginwrapper input#remember_me { margin: 0 !important; min-height: 10px; width: auto; box-shadow: 0px 0px; background:none; padding-left:0px!important; padding-right:5px!important; } 

After determining:

 .loginwrapper input#remember_me{margin:0!important;min-height:10px;width:auto;box-shadow:0 0;background:0 0;padding-left:0!important;padding-right:5px!important} 

Now you can see that the value of "background: none" is changed to "background: 0 0". How can I make sure that it does not make any changes to my CSS, except for its exception.

+5
source share
2 answers

Aah, looking at issues with pure css on Github, I found this one where it identifies that background:none; "optimized" for background:0 0; . Please note that this is 1 character shorter. I think this is quite common in uglification libraries, but it should be separated from pure "minimization", which, IMO, should only remove non-essential information, such as spaces.

Looking at the options for clean-css (which you can use in your cssmin configuration), I don’t think there is a way to disable this, I tried the shorthandCompacting and advanced options with no luck. Unfortunately, it looks like you are stuck with this. However, background:0 0; should work the same as background:none; .

+4
source

You can try restructuring: false option

+1
source

Source: https://habr.com/ru/post/1210561/


All Articles