0

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

它只是复制 App 文件夹,但没有任何子文件夹和文件。我怎样才能让它复制所有内容?任何帮助将非常感激。请在下面查看我的 gruntfile。

谢谢 - 克里斯

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']);


};
4

1 回答 1

0

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

copy: {
    main: {
        files: {
            'build': 'App'
        }
    }
}
于 2013-11-12T18:38:46.430 回答