-1

Good people! I'm learning the power of Grunt and have a question.

I've got 20 separately named folders in my dev environment. Inside each folder there are four folders also with separate names. Inside each of the four folders is an index.html, js, css, spritesheet file and a folder called assets.

What I'd love to be able to do is run a grunt task(s) that could read each of 20 folders and their sub-folders, delete the assets folder and create a copy of the updated/optimized dev folder structure, into a prod folder ready for deployment.

Any help is greatly appreciated, Blake

blake ferm
  • 39
  • 5

1 Answers1

0

to delete the assets folder you can use the grunt-contrib-clean plugin. to copy all files into a prod env you can use the grunt-contrib-copy plugin:

so your gruntfile could look like the following:

module.exports = function(grunt) {
    grunt.initConfig({
        copy: {
            main: {
                expand: true,
                src: 'rootfolder/**',
                dest: '/path/to/prod-env/'
            }
        },

        clean: {
            main: ['rootfolder/*/assets/']
        }
    });

    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-contrib-copy');

    grunt.registerTask('build', [ 'clean:main', 'copy:main' ]);
};
chresse
  • 5,486
  • 3
  • 30
  • 47