I have done some related-work recently where we target different deployments.
The basic requirement was configuration based on 3 profiles (production, integration/test, local) that included:
configuration of 1 or many REST endpoints
the root base the application it self. (contained usually in the index.html)
The gulp-config works well for project structure/resources related things but it works less good when deployment-related configuration is needed.
What I did was:
created a /profile/ directory containing a json file per "profile target"
{
"end-point-url" : ''http://...."
"app-root-base" : "/test/"
}
Extend the gulpfile.js/gulp.config.js files to add a profile variable so that we can call:
gulp build --profile production
in the case a /profile/production.json file exists, then that configuration would be used.
There would be some constants/configuration js file that has some @@constants_ids that would be replaced when matched.
Process the JS for constant replacement
Text-replace the to whatever is declared under "app-root-base"
The challenge was of course how to keep the configuration working for both:
1)the "production" processed/optimized code/application. (easy case since it just go through the regular gulp stream)
2)the local dev non-optimized. (difficult case)
The reason why #2 is difficult is because the resources js/html are not processed by gulp, therefore no text-replace nor constant js can be generated that would be recognized. I don't like my solution since @@constants_ids has default value in case it does not get replaced.
=> Effectively making /profile/localdev.json a difficult case.
Also, one cannot cleanly update index.html, otherwise, it would be check-in depending on the profile you used on the gulp call. (this is less of a problem, as the root "/" is good enough)
Perhaps there would be a more cleaver way to achieve it ?
(I could provide the changes I did, even if they are clearly ugly.)
Hi John,
I have done some related-work recently where we target different deployments.
The basic requirement was configuration based on 3 profiles (production, integration/test, local) that included:
The gulp-config works well for project structure/resources related things but it works less good when deployment-related configuration is needed.
What I did was:
The challenge was of course how to keep the configuration working for both: 1)the "production" processed/optimized code/application. (easy case since it just go through the regular gulp stream) 2)the local dev non-optimized. (difficult case)
The reason why #2 is difficult is because the resources js/html are not processed by gulp, therefore no text-replace nor constant js can be generated that would be recognized. I don't like my solution since @@constants_ids has default value in case it does not get replaced. => Effectively making /profile/localdev.json a difficult case. Also, one cannot cleanly update index.html, otherwise, it would be check-in depending on the profile you used on the gulp call. (this is less of a problem, as the root "/" is good enough)
Perhaps there would be a more cleaver way to achieve it ?
(I could provide the changes I did, even if they are clearly ugly.)
Cheers