GRUNT 添加COPY文件任务

npm install grunt-contrib-copy --save-dev
Gruntfile.js 配置文件中增加
module.exports=function(grunt){
    ...
    grunt.initConfig({
        ...
        copy: {
            main: {
                files: [{
                    expand: true,
                    cwd: 'jsCssSrc/js/',
                    src: ['*.min.js'],
                    dest: 'common/js/',
                },{
                    expand: true,
                    cwd: 'jsCssSrc/css/',
                    src: ['*.min.css'],
                    dest: 'common/css/',
                }]
            },
            build: {
                files: [{
                    expand: true,
                    cwd: 'jsCssSrc/coreJs/',
                    src: ['*.min.js'],
                    dest: 'common/coreJs/',
                },{
                    expand: true,
                    cwd: 'jsCssSrc/coreCss/',
                    src: ['*.min.css'],
                    dest: 'common/coreCss/',
                }]
            }
        },
        ...
    })
    
    ...
    grunt.loadNpmTasks('grunt-contrib-copy');
    ...
    
    grunt.registerTask('default',[...'copy:main',...]);
    
    ...
}

然后就可以执行
grunt copy:main
或者
grunt
就会执行default任务项启动 copy:main 任务

标签: none

添加新评论