Grunt复制任务不会复制所有文件夹和文件

时间:2013-11-12 14:59:05

标签: asp.net-mvc gruntjs grunt-contrib-copy

我对grunt有点新意,并试图让它将src目录(App)的全部内容复制到dest目录(build)。

它只复制App文件夹,但没有复制子文件夹和文件。我怎样才能让它复制一切?任何帮助将非常感激。请参阅下面的grunt文件。

谢谢 - 克里斯

module.exports = function(grunt) {


    // INITIALIZE TASKS
    grunt.initConfig({    


        // PACKAGE INFO
        pkg: grunt.file.readJSON('package.json'),


        // ENVIRONMENT SETTINGS
        env: 'dev',


        // CLEAN BUILD FOLDER
        clean: {
            options: {
                force: true
            },

            build: [
                'build/App/buildlates',
                'build/App/styles/app',
                'build/App/styles/vendor',
                'build/App/scripts/app',
                'build/App/scripts/vendor',
                'build/App/scripts',
                'build/App/styles',
                'build/App/img',
                'build/App',
                'build'
            ]
        },


        // COPY DEV CODE INTO BUILD
        copy: {

            main: {
                files: {
                    'build/': ['App/**']
                }

            }
        },


        // JSHINT
        jshint: {

            files: [
                    'App/scripts/app/angular/**/*.js'
            ],
            options: {
                ignores: [
                    'App/scripts/app/*.js',
                    'App/scripts/app/angular/directives/vendor/**'
                ]
            }

        },


        // LESS PROCESSING
        less: {

            development: {
                options: {
                    paths: ['build/App/styles/app']
                },
                files: {
                    'build/App/styles/app/css/main.css': 'build/App/styles/app/main.less',
                    'build/App/styles/app/css/another.css': 'build/App/styles/app/another.less'
                }
            }

        },


        // CONCAT
        concat: {

            css : {
                src: ['build/App/styles/app/css/*.css'],
                dest: 'build/App/styles/app/css/styles.css'
            },

            js : {
                src: [
                        'build/App/scripts/app/angular/*.js',
                        'build/App/scripts/app/angular/objects/*.js',
                        'build/App/scripts/app/angular/modules/*.js',
                        'build/App/scripts/app/angular/services/*.js',
                        'build/App/scripts/app/angular/directives/*.js',
                        'build/App/scripts/app/angular/filters/*.js',
                        'build/App/scripts/app/angular/controllers/*.js'
                ],
                dest: 'build/App/scripts/app/angular/release/app.js'
            }

        },


        // MINIMIZE CSS    
        cssmin: {

            minify: {
                expand: true,
                cwd: 'build/App/styles/app/css/',
                src: ['styles.css', '!*.min.css'],
                dest: 'build/App/styles/app/css/',
                ext: '.min.css'
            }

        },


        // MINIMIZE JAVASCRIPT
        'jsmin-sourcemap': {
            all: {
                src: ['build/App/scripts/app/angular/release/app.js'],
                dest: 'build/App/scripts/app/angular/release/app.min.js',
                destMap: 'build/App/scripts/app/angular/release/app.js.map'
            }
        },


        // WATCH FOR CHANGES
        watch: {

            src: {
                options: { livereload: true },
                files: ['App/scripts/app/**', 'App/styles/app/*.less', 'App/templates/**'],
                tasks: ['jshint', 'less', 'preprocess'],
            }

        },


        // PREPROCESS HTML BUILD DIRECTIVES
        preprocess: {

            options: {
                context: {
                    ENVIRONMENT: '<%= env %>'
                }
            },

            html: {
                src: 'App/templates/environmentChecker.html',
                dest: 'build/App/templates/environmentChecker.html'
            }


        }


    });



    // LOAD TASKS
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-contrib-less');
    grunt.loadNpmTasks('grunt-contrib-cssmin');
    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-jsmin-sourcemap');
    grunt.loadNpmTasks('grunt-contrib-jasmine');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-preprocess');


    // REGISTER TASKS
    grunt.registerTask('default', ['clean:build', 'copy', 'jshint']);
    grunt.registerTask('dev', ['jshint', 'clean:build', 'clean:build', 'copy', 'less:development', 'preprocess', 'watch']);
    grunt.registerTask('prod', ['jshint', 'clean:build', 'clean:build', 'copy', 'less:development', 'concat:css', 'cssmin', 'concat:js', 'jsmin-sourcemap', 'preprocess']);


};

1 个答案:

答案 0 :(得分:0)

您指定的配置仅查看根目录;如果你想要整个文件夹,为什么不直接指定?

copy: {
    main: {
        files: {
            'build': 'App'
        }
    }
}