Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Processing multiple files with a wildcard. #21

Closed
w-jbarlow opened this issue Sep 18, 2013 · 3 comments
Closed

Processing multiple files with a wildcard. #21

w-jbarlow opened this issue Sep 18, 2013 · 3 comments

Comments

@w-jbarlow
Copy link

New feature request. I would like to be able to specify source as a wildcard, and destination as a directory. I have many html files (and JS files and CSS files) that I need to process for several environments over and over. Currently it appears that you can only specify a single file per line or per preprocess task. Unless I am mistaken, it seems that only inline will let you do wildcard preprocessing.

preprocess: {
html: {
src: './src/*/.html',
dest: './processed'
}
}

@metrofun
Copy link

+1 That would be very handy

@jsoverson
Copy link
Owner

You can dynamically build the files array with grunt to support this, and it doesn't need to be done per-task

http://gruntjs.com/configuring-tasks#building-the-files-object-dynamically

@mhulse
Copy link

mhulse commented Oct 27, 2013

You can dynamically build the files array with grunt to support this, and it doesn't need to be done per-task
http://gruntjs.com/configuring-tasks#building-the-files-object-dynamically

That worked perfectly for me. Thanks @jsoverson for the pointer.

For anyone else wanting to see an example using grunt-preprocess:

/*----------------------------------( PREPROCESS )----------------------------------*/

/**
 * Grunt task around preprocess npm module.
 *
 * @see https://github.com/onehealth/grunt-preprocess
 * @see https://github.com/onehealth/preprocess
 * @see http://gruntjs.com/configuring-tasks#building-the-files-object-dynamically
 */

preprocess : {

    options : {

        context : {

            title : '<%= pkg.title %>',
            description : '<%= pkg.description %>',
            name : '<%= pkg.name %>',
            version : '<%= pkg.version %>',
            homepage : '<%= pkg.homepage %>',

        },

    },

    dev : {

        /*
        files : {

            '../dev/index.html' : './files/templates/index.html',
            '../dev/layout.html' : './files/templates/layout.html',

        }
        */

        files: [

            {

                expand: true,
                cwd: './files/templates/',
                src: ['**/*.html'],
                dest: '../dev/',
                ext: '.html',

            },

        ],

    },

},

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants