Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

grunt-ng-constant targets not consistently working

I am running into a weird issue with grunt-ng-constant where only 2 out of 3 of the targets work.

My configuration looks like the following:

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'
        }
      }
    }
  }
})

and I have the following tasks being registered

 grunt.registerTask('development', [
    'ngconstant:development'
 ]);

 grunt.registerTask('staging', [
    'ngconstant:staging'
 ]);

 grunt.registerTask('production', [
   'ngconstant:production'
 ]);

If I run the two following commands, everything works fine and the config.js file is generated and looks great.

grunt development
grunt staging

but running grunt production doesn't generate the config.js file. I can't seem to figure out why this is happening.

like image 795
TheJediCowboy Avatar asked Sep 08 '15 05:09

TheJediCowboy


1 Answers

I both developmend and staging tasks you are generating config.js file in a path beginning with <%= yeoman.app %>, but in production you are using one that starts with <%= yeoman.dist %>.

I would check if the second path (or yeoman.dist) exists.

like image 161
slomek Avatar answered Nov 09 '22 06:11

slomek