Is there an array placeholder in the gruntjs

Is there a way to have a placeholder for array type?

I have this:

    'closure-compiler': {
        dev: {
            files: {
                '<%= buildDirDev %>js/<%= outputMinJsName %>': [
                    '<%= sourceJsPath %>namespace.js',
                    '<%= sourceJsPath %>utils.js',
                    '<%= sourceJsVersionPath %>',
                    '<%= sourceJsPath %>game/CollidableContainer.js',
                    '<%= sourceJsPath %>game/Button.js',
                    '<%= sourceJsPath %>game/LabelledButton.js'
                ]
            },
        production: {
            files: {
                '<%= buildDir %>js/<%= outputMinJsName %>': [
                    '<%= sourceJsPath %>namespace.js',
                    '<%= sourceJsPath %>utils.js',
                    '<%= sourceJsVersionPath %>',
                    '<%= sourceJsPath %>game/CollidableContainer.js',
                    '<%= sourceJsPath %>game/Button.js',
                    '<%= sourceJsPath %>game/LabelledButton.js'
                ]
            },

and I would like to have it as:

     files: [
                    '<%= sourceJsPath %>namespace.js',
                    '<%= sourceJsPath %>utils.js',
                    '<%= sourceJsVersionPath %>',
                    '<%= sourceJsPath %>game/CollidableContainer.js',
                    '<%= sourceJsPath %>game/Button.js',
                    '<%= sourceJsPath %>game/LabelledButton.js'
     ],
    'closure-compiler': {
        dev: {
            files: {
                '<%= buildDirDev %>js/<%= outputMinJsName %>': <%= files %>
            },
        production: {
            files: {
                '<%= buildDir %>js/<%= outputMinJsName %>': <%= files %>
            },

then I could maintain only one list instead of 2

Upvotes: 1

Views: 22

Answers (1)

Eria
Eria

Reputation: 3182

I don't know about placeholders, but you could try declaring the array as javascript variable outside the grunt.initConfig() call.

module.exports = function( grunt ){

    // ...

    var filesArray = [
        '<%= sourceJsPath %>namespace.js',
        '<%= sourceJsPath %>utils.js',
        '<%= sourceJsVersionPath %>',
        '<%= sourceJsPath %>game/CollidableContainer.js',
        '<%= sourceJsPath %>game/Button.js',
        '<%= sourceJsPath %>game/LabelledButton.js'
    ];

    grunt.initConfig({
        'closure-compiler': {
            dev: {
                files: {
                    '<%= buildDirDev %>js/<%= outputMinJsName %>': filesArray
                }
            },
            production: {
                files: {
                    '<%= buildDir %>js/<%= outputMinJsName %>': filesArray
                }
            }
        }
    });

}

Upvotes: 2

Related Questions