Skip to content

feat : Added ability for Gulp workflow to inject constants into app module based on json config files #650

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from

Conversation

chalettu
Copy link

@chalettu chalettu commented Jul 1, 2015

This type of functionality had been discussed before in previously closed tickets but no one actually submitted a pull req for this functionality. I had a need to be able to have different config files based on deployment environment and wanted to enhance the existing workflow to support this so I can easily generate constants based on an environment parameter.

Please let me know your thoughts and feedback.

This would essentially work if you added a --env xxx to whichever gulp command you run from the generator.
Your generator has a bunch of moving parts, let me know if you think I have missed anything or think it needs some further enhancements.

Verified

This commit was signed with the committer’s verified signature.
bagder Daniel Stenberg
…ased on command line --env variable . Useful for angular projects that have different app api keys based on env or different rest endpoints based on deployed environment
@Swiip
Copy link
Owner

Swiip commented Jul 8, 2015

It has been discussed many times. For me, it was more for a recipes than a built in feature. But I'm open to discuss it once again.

@chalettu
Copy link
Author

Thank you for considering it. I will take a look at updating the tests so they pass. This feature of environments was pretty important and critical for the angular mobile apps and web sites I write. With this little addition it makes it easier for me to manage having multiple backends. I would think this is a fairly common problem. How to handle different env. I like using this gulp workflow to handle it because it makes it easy to add this parameter on my CI builds when I deploy to production or any other Env.

Chris Hale added 2 commits August 5, 2015 11:08

Verified

This commit was signed with the committer’s verified signature.
bagder Daniel Stenberg
… for first time

Verified

This commit was signed with the committer’s verified signature.
bagder Daniel Stenberg
//var ENV = JSON.parse(fs.readFileSync('./src/app/env_configs/config-' + environment + '.json', 'utf8')).ENV;

gulp.task('env-config', function () {
return gulp.src('src/app/env_configs/config-' + environment + '.json')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line should read from the config

return gulp.src(path.join(conf.paths.src, '/app/env_configs/config-' + environment + '.json'))

@loren138
Copy link

This is exactly what I needed so I manually merged it in. That produced a few comments (above) on some code lines. It would also be nice if it didn't put the config json files in my dist folder since they are already merged. It would also be nice of the rendered constants.config.js wasn't in the src folder (maybe it could go in .tmp or serve?) I don't understand gulp enough to fix either of those though. Overall, thanks so much. There is no way I could have gotten this to work without this PR.

One more thing, it would be nice if you made gulp watch the config files and cause browser serve to refresh when they change.

@zckrs
Copy link
Collaborator

zckrs commented Sep 2, 2015

@zckrs zckrs closed this Sep 2, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants