atticoos / gulp-ng-config

:wrench: Create AngularJS constants from a JSON config file
MIT License
173 stars 35 forks source link

Fixed an issue where environment constants would prevent optional consta... #22

Closed danwkennedy closed 9 years ago

danwkennedy commented 9 years ago

...nts from getting written to the output file.

atticoos commented 9 years ago

Ty for fixing this oversight!

Closes https://github.com/ajwhite/gulp-ng-config/issues/21

clabnet commented 9 years ago

I'm not sure that working:

{
  "dev": {
    "EnvironmentConfig": {
      "api": "http://localhost/"
    }
  },
  "production": {
    "EnvironmentConfig": {
      "api": "https://api.production.com/"
    }
  }
}
gulp.task('ngConfig', function () {
  return gulp.src(config.configJson)
    .pipe(gulpNgConfig('dcc.config'), {
      environment: 'production'
    })
    .pipe(gulp.dest(config.scripts))
});
angular.module('dcc.config', [])
.constant('production', {"EnvironmentConfig":{"api":"https://api.production.com/"}});
angular.module('dcc.config', [])
.constant('dev', {"EnvironmentConfig":{"api":"http://localhost/"}})
.constant('production', {"EnvironmentConfig":{"api":"https://api.production.com/"}});

Maybe I did not understand how to use it?

Thank you, bye

atticoos commented 9 years ago

It looks like your gulpfile has an incorrect syntax:

.pipe(gulpNgConfig('dcc.config'), {
  environment: 'production'
})

You're passing the configuration as a second argument to pipe, rather than gulpNgConfig

You'll want to tweak it so it's passed to gulpNgConfig:

.pipe(gulpNgConfig('dcc.config', {
  environment: 'production'
}))

More details here

clabnet commented 9 years ago

You are right, it is my mistake. It run, grazie.

atticoos commented 9 years ago

:smile: :+1: