GruntJS:无法调用undefined的方法过滤器

时间:2014-10-07 13:00:41

标签: javascript gruntjs grunt-contrib-uglify

我是grunt的新手并尝试在一个简单的项目上安装它。它有效,但当我试图运行' ugilfy'我的文件我一直收到这个错误:

cannot call method   'filter' of undefined'

这是我的grunt文件(Gruntfile.js),保存在我项目的根目录中:

module.exports = function(grunt)


{

grunt.initConfig({

    uglify: 
    { 
        options: 
        {
            mangle: true, 
            compress:true, 
            sourceMap: "dist/app.map", 
            banner: "/*  2014 */" 
        },

        //set of files where the plugin works on, (files which we can affect with our plugins like uglify)
        // culd be dev or production 
        target: 
        {

            //folder name equal to the JS object!!!
            js: "js/app.js", 
            dest: "dist/app.min.js"
        }
    }

});



//load plug-ins
grunt.loadNpmTasks('grunt-contrib-uglify'); 


};

我真的不知道为什么它不起作用。我尝试在谷歌搜索,但我找不到任何答案。

1 个答案:

答案 0 :(得分:0)

uglify.target缺少src属性。

更改

js: "js/app.js",

src: "js/app.js",

它应该可以正常工作。

有关指定来源和目的地的更多信息,请in the Grunt docs