gruntjsgrunt-contrib-cssmin

grunt-contrib-cssmin takes 10 minutes to complete


I currently have an issue that my grunt-contrib-cssmin task takes nearly 10 minutes to complete. This problem occured after I updated grunt and all plugins to current versions. I did not update them for nearly a year before. Before the update, the cssmin task took arount 5 seconds to complete.

What could be the cause of this increase in run time after updating? My task definition is:

    cssmin: {
        target: {
            options: {
                banner: '/*! app.min.css <%= grunt.template.today("dd-mm-yyyy") %> */\n',
                filename: 'app.min.' + grunt.template.today("ddmmyyyyHHMMss") + '.css'
            },
            files: {
                'app/css/<%= cssmin.target.options.filename %>': [
                    'app/lib/bower_components/angular-motion/dist/angular-motion.css',
                    'app/lib/bower_components/ng-sortable/dist/ng-sortable.min.css',
                    'app/lib/bower_components/pines-notify/pnotify.core.css',
                    'app/lib/bower_components/pines-notify/pnotify.picon.css',
                    'app/lib/bower_components/pines-notify/pnotify.buttons.css',
                    'app/lib/bower_components/pines-notify/pnotify.history.css',
                    'app/lib/bower_components/angular-bootstrap-colorpicker/css/colorpicker.css',
                    'app/lib/bower_components/ng-sortable/dist/ng-sortable.min.css',
                    'app/lib/patches/ui.dynatree.css',
                    'app/lib/bower_components/selectize/dist/css/selectize.bootstrap3.css',
                    'app/lib/bower_components/angular-ui-grid/ui-grid.css',
                    'app/lib/bower_components/angular-resizable/angular-resizable.min.css',
                    'app/css/screen.css',
                    'app/css/ie.css'
                ]
            }
        }
    },

Solution

  • Found the cause of the issue. grunt-contrib-cssmin uses internally the task clean-css. This task has an option "advanced". This option can also be set for grunt-contrib-cssmin, which delegates it to clean-css.

    If the advanced option is set to true, the execution times are around 10 minutes. if it is set to false, my execution times for this task are around 6 seconds.