grunt-usemin是否包含concat,uglify,cssmin?

时间:2016-03-08 14:36:14

标签: angularjs node.js gruntjs grunt-usemin grunt-contrib-uglify

下面是我的Gruntfile.js

grunt.initConfig({
useminPrepare: {
            html: 'Menu.htm',
            options: {
                dest: 'build'
            }
        },
        usemin: {
            html: ['build/Menu.html']
        },
        copy: {
            generated: {
                src: 'Menu.htm',
                dest: 'build/Menu.html'
            }
        }
    });


    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-contrib-cssmin');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-usemin');

    grunt.registerTask('build', [
        'copy:generated',
        'useminPrepare',
        'concat',        
        'cssmin',
        'uglify',
        'usemin'
    ]);

如果我运行上面的代码,我会收到错误,说“不”#34; concat"发现任务。要么我必须从registerTask中删除它,要么我必须在config中添加任务。但根据教程,我浏览了如果他们添加usemin然后concat uglify cssmin将在我运行grunt时自动添加。我为什么不自动获取?为什么我必须再次单独添加所有这些任务?

1 个答案:

答案 0 :(得分:0)

根据readme,您需要先安装它。

要安装这些插件,请运行:

$ npm install grunt-contrib-concat grunt-contrib-uglify grunt-contrib-cssmin grunt-filerev --save-dev

我建议您查看回购并发出号码313