首页 > grunt 运行不成功

grunt 运行不成功

文件结构如下:

module.exports = function(grunt){
    grunt.initConfig({
        pkg:grunt.file.readJSON('package.json'),
        uglify:{
            options:{
                stripBanners:true,
                banner: '/*!<%=pkg.name%>*/'
            },
            build:{
                options: {
                    report: 'min'
                },
                files:{
                    'build/test.min.js':['test/test.js']
                }
            }
        }
    });

    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.registerTask('default',[]);
};

运行结果只用Done,没有生成文件,为什么?


因为你的default任务里什么也没写,你好歹把uglify的任务填进去吧:

module.exports = function(grunt){
    grunt.initConfig({
        pkg:grunt.file.readJSON('package.json'),
        uglify:{
            options:{
                stripBanners:true,
                banner: '/*!<%=pkg.name%>*/'
            },
            build:{
                options: {
                    report: 'min'
                },
                files:{
                    'build/test.min.js':['test/test.js']
                }
            }
        }
    });

    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.registerTask('default', ['uglify']);
};
【热门文章】
【热门文章】