I encountered a strange issue with grunt-ng-constant
where only 2 out of the 3 targets are working.
Here is how my configuration is set up:
grunt.initConfig({
ngconstant: {
options: {
space: ' ',
wrap: '"use strict";\n\n {%= __ngModule %}',
name: 'config'
},
// Environment targets
development: {
options: {
dest: '<%= yeoman.app %>/scripts/config.js',
},
constants: {
ENV: {
name: 'development',
apiEndpoint: 'http://your-development.api.endpoint:3000'
}
}
},
staging: {
options: {
dest: '<%= yeoman.app %>/scripts/config.js',
},
constants: {
ENV: {
name: 'staging',
apiEndpoint: 'http://your-staging.api.endpoint:3000'
}
}
},
production: {
options: {
dest: '<%= yeoman.dist %>/scripts/config.js',
},
constants: {
ENV: {
name: 'production',
apiEndpoint: 'http://api.livesite.com'
}
}
}
}
})
I have set up tasks for each environment like so:
grunt.registerTask('development', [
'ngconstant:development'
]);
grunt.registerTask('staging', [
'ngconstant:staging'
]);
grunt.registerTask('production', [
'ngconstant:production'
]);
When I run the commands grunt development
and grunt staging
, everything works as expected generating the config.js
file. However, running grunt production
fails to generate the file without any clear reason.