Skip to content

Commit

Permalink
Merge pull request #37 from jirihelmich/patch-1
Browse files Browse the repository at this point in the history
Docs update - using environment-dependent settings in configuration
  • Loading branch information
jsoverson committed Jun 30, 2015
2 parents 37d6b51 + e4f7e7e commit 27ad077
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,40 @@ yourtask : {
}
```

## Environment-specific configuration

In order to configure your tasks based on the environment, you need to define a task and use templates:

```
grunt.initConfig({
env: {
dev: {
MY_CONST: 'a'
},
prod: {
MY_CONST: 'b'
}
},
myTask: {
options: {
myOpt: <%= MY_CONST %>
}
}
});
grunt.registerTask('loadconst', 'Load constants', function() {
grunt.config('MY_CONST', process.env.MY_CONST);
});
grunt.registerTask('default', [
'env:dev',
'loadconst',
'myTask'
]);
```

## Important note on data types

Environment variables are strings only. If you attempt to assign complex objects, they will be converted to strings.
Expand Down

0 comments on commit 27ad077

Please sign in to comment.