gruntjsgrunt-contrib-cssmin

Could not create a minified css file using grunt-contrib-cssmin


I am using grunt first time, I could able to concat css file using grunt-contrib-concat but I am getting following error while creating minified css file using grunt-conrib-cssmin

Error is :

>> TypeError: Cannot call method 'clone' of undefined
Warning: CSS minification failed. Use --force to continue.

My package.json file is :

    {
        "name": "grunt-test-project",
        "description":"testing grunt css and js files minification",
        "repository":"",
        "version": "0.1.0",
        "devDependencies": {
            "grunt": "~0.4.5",
            "grunt-contrib-concat": "~0.5.0",
            "grunt-contrib-cssmin" : "~0.10.0"
        }
    }

My Gruntfile.js file is :

module.exports = function(grunt) {

    // Project configuration.
    grunt.initConfig({

        pkg: grunt.file.readJSON('package.json'),

        concat: {
            css: {
                src: [
                    'css/popup.css', 'css/styles_layouts.css', 'css/style.css', 'css/fileuploader.css','css/uniform.default.css',
                    'css/login_popup.css','css/validationEngine.jquery.css','css/ui-custom/jquery-ui.css'
                ],
                dest: 'css/build/combined.css'
            }

        },

        cssmin: {
            css:{
                src: 'css/build/combined.css',
                dest: 'css/build/combined.min.css'
            }
        }
    });


    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-contrib-cssmin');

    // Default task(s).
    grunt.registerTask('default', ['cssmin']);

}

It will help me lot if you could provide some solution.

Thanks you


Solution

  • Your code is a bit different than the one at the grunt-contrib-cssmin documentation page.`

    cssmin: {
      options: {
        shorthandCompacting: false,
        roundingPrecision: -1
      },
      target: {
        files: {
          'output.css': ['foo.css', 'bar.css']
        }
      }
    }
    

    `