I'm using grunt-replace to perform some substitutions of variables according to the environment (dev/testing/production). Those variables are set like this:
config: {
dev: {
options: {
variables: {
base_url: 'localhost'
}
}
},
testing: {
options: {
variables: {
base_url: 'testing.example.com'
}
}
},
prod: {
options: {
variables: {
base_url: 'production.example.com'
}
}
}
},
Then I'm replacing the variables with grunt-replace, like this:
replace: {
main: {
options: {
patterns: [
{
match: 'BASE_URL',
replacement: '<%= grunt.config.get("base_url") %>'
}
]
},
src: 'src/main.js' ,
dest: 'dist/main.js'
},
}
Since I'm using an .env file configured for the mentioned environments (.env.development, .env.testing / .env.production), is it possible to tell grunt-env to load that file and perform the replacements with this instead with grunt-config? I would like to do this so that to avoid having duplicated code for setting those variables in each environment.
Thanks!
I'm using grunt-replace to perform some substitutions of variables according to the environment (dev/testing/production). Those variables are set like this:
Then I'm replacing the variables with grunt-replace, like this:
Since I'm using an
.envfile configured for the mentioned environments (.env.development, .env.testing / .env.production), is it possible to tell grunt-env to load that file and perform the replacements with this instead with grunt-config? I would like to do this so that to avoid having duplicated code for setting those variables in each environment.Thanks!