logankoester/grunt-environment — pull request #4 by jaetask (2014-02-22 20:54:14+00:00)
Title: Extend to allow pulling environment vars from global config

Hi,

I have extended the plugin to allow the following usage within the GruntFile.

Consider this config file:
{
development: {
jsFileName: 'js',
cssFileName: 'css'
},
production: {
jsFileName: 'production.min.js',
cssFileName: 'production.min.css'
},
environment: {
default: 'development',
environments: ['development', 'production'],
version: function(){
return grunt.file.readJSON('package.json')['version']
}
}
}

Allows this usage:
sed: {
js: {
path: 'build/index.html',
pattern: '%SRC_JAVASCRIPT%',
replacement: '<%= grunt.environmentVar("jsFileName") %>',
},
css: {
path: 'build/index.html',
pattern: '%SRC_CSS%',
replacement: '<%= grunt.environmentVar("cssFileName") %>',
}
},

Which pulls out different values depending on the current environment within strings. very cool :)

Please consider pulling into the main plugin.

Thanks
Jae.