Single config files for all tasks

23 views Asked by At

I'd like to make configuration of grunt tasks a bit easier. Currently I've got a lot of different configuration files, like a .csslintrc, jshintrc, bower.json and so on.

It would be really cool if I could concatenate all these configuration files into one single file. This configuration file could look something like

{
  "csslint": {
    "important": 1,
    // ...
  },
  "jshint": {
    //...
  },
  "bower": {
    //...
  }
}

My only solution so far would be using a preprocessor and simply insert the options in the tasks (I couldn't figure out how to insert options otherwise). But this doesn't seem to be a very beautiful way...

1

There are 1 answers

0
Xavier Priour On

Most (all?) grunt tasks let you define options in the Gruntfile itself instead of their respective .*rc files. So if you do that, you nearly get your one single configuration file for free.

For example:

jshint: {
    dist: {
        options: {
            curly: true,
            eqeqeq: true,
        },
        src: ['path/to/**/*.js']
    }
},
csslint: {
    dist: {
        options: {
            import: 2
        },
        src: ['path/to/**/*.css']
    }
},
bower: {
    install: {
        options: {
            targetDir: './lib',
            layout: 'byType',
            install: true,
            verbose: false,
            cleanTargetDir: false,
            cleanBowerDir: false,
            bowerOptions: {}
        }
    }
}