运行grunt插件grunt-contrib-cssmin时出错

时间:2016-01-03 20:37:36

标签: javascript node.js gruntjs grunt-contrib-cssmin

Grunt新手在这里。当我运行grunt任务grunt-contrib-cssmin时,我收到以下错误。现代化的任务似乎正在发挥作用:

Running "cssmin:target" (cssmin) task
Warning: pattern.indexOf is not a function Use --force to continue.

这是我的gruntfile.js

module.exports = function(grunt) {
    grunt.initConfig ({
    // Do grunt-related things in here
        pkg: grunt.file.readJSON('package.json'),

        modernizr_builder: {
            build: {
                options: {
                    features: 'pointerevents',
                    dest: 'javascripts/modernizr-custom.js'
                }
            }
        },

        cssmin: {
          /*options: {
            shorthandCompacting: false,
            roundingPrecision: -1
          },*/
          target: {
            files: {
                files: {
                    'css/min/bigvideo.min.css': ['css/bigvideo.css']
                }
            }
          }
        },              
    });
    grunt.loadNpmTasks('grunt-modernizr-builder');
    grunt.loadNpmTasks('grunt-contrib-cssmin');
    grunt.registerTask('default',['modernizr_builder', 'cssmin']);
};

这是我的package.json文件,我在项目目录中安装了grunt-contrib-css

{
  "name": "bootstrap-wp-less",
  "version": "1.0.0",
  "description": "No desc",
  "main": "index.js",
  "scripts": {
    "test": "test"
  },
  "author": "Me",
  "license": "ISC",
  "devDependencies": {
    "grunt": "^0.4.5",
    "grunt-contrib-cssmin": "^0.14.0",
    "grunt-modernizr-builder": "^0.1.7"
  }
}

1 个答案:

答案 0 :(得分:0)

我的错误发生在cssmin任务中,更改为:

cssmin: {
          /*options: {
            shorthandCompacting: false,
            roundingPrecision: -1
          },*/
          target: {
            files: {
                'css/min/bigvideo.min.css': ['css/bigvideo.css']
            }
          }
        },