-
Notifications
You must be signed in to change notification settings - Fork 136
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
Use specific files for different enviroments #134
Comments
Totally agree. There must be some guidance out there from Ionic (or Angular2) about the best way of doing this? The guys at angular2-seed are using different build tasks in gulp per environment (which would take care of the copying for you, I guess). I don't have time to dig into it right now. https://github.com/mgechev/angular2-seed/blob/master/gulpfile.ts#L13-L67 It's really a question for the Ionic guys, they need to recommend a way for this to be done. |
My first attempt was to make an cordova hook -but we need to run the task before So I added this new task gulp.task('enviroment', function(){
var env = process.env.ENV || 'dev';
var options = {
src: 'config/' + env + '/**/*.*',
dest: './',
onComplete: function() {
console.log('All env files were copied.');
},
onError: function(err) {
console.error(err.toString());
this.emit('end');
}
}
return gulp.src(options.src)
.pipe(gulp.dest(options.dest))
.on('end', options.onComplete)
.on('error', options.onError);
}); and I added as a dependency to gulp.task('scripts', ['enviroment'], copyScripts); So now, to make a build for android in the QA enviroment, you need to run |
Looks good, I think the solution has to be a gulp script at the moment. I keep being reminded (#131, #38 (comment)) that Ionic are moving back to webpack. Not sure what the setup is going to be after that with regard to gulp, but having environment specific config files and [insert task runner here] copying them at build time is the way to go. Incidentally, our closed source project will be going to prod within the next couple of weeks, so we'll need to address this ourselves. If we deviate from the pattern above I'll be sure to raise here for discussion. For now I'd like to close this (I'll add a link from the blog post). Is that OK with you or is there something else to cover? |
Ah I hadn't thought of doing a PR! It's 'cause I don't see myself as having ownership of Ionic's gulpfile (I rarely touch it, if ever). I do think it's a good idea to have this as an example though. |
#135 closed |
It would be awesome to have files for each environment (development, production, qa, etc) available on
/config
, and to copy them just before running the server/compiling.I am thinking on using different
config.xml
, and also a static class storing API's urls.The text was updated successfully, but these errors were encountered: