samedi 9 mai 2015

Grunt template variables and if else

I have some template variables in my Gruntfile for my dist folders. I also want to use them in an if else statement to adjust the configuration of some tasks.

Here a short version of my Gruntfile:

module.exports = function(grunt) {
    grunt.initConfig({

        // Variables
        path: {
            develop: 'dev/',
            output: 'output/'
        },

        // Clean empty task
        cleanempty: {
            output: {
                src: '<%= path.output %>**/*'
            }
        },

        // Sync
        sync: {
            output: (function(){
                console.log(grunt.config('path.output'));  // Returns undefined

                if(grunt.config('path.output') === 'output/') {
                    return {
                        // Config A
                    }

                } else {
                    return {
                        // Config B
                    }
                }
            }())
        }

unfortunately I cant get it work. grunt.config('path.output') returns undefined. How can I read Grunt template variables? Tips for a way better solution, I also like to hear.

Aucun commentaire:

Enregistrer un commentaire