We have 3 environment (qa, dev and prod) and we wish to only build our app once and during deployment we would instruct the ember app to load the right config file.
Alternatively instead of loading an hardcoded file is there a way for the app to remotely fetch the config file ? Like this we could remotely modify some config without the need to build and redeploy ?
Then in runtime we parse that object and save it in service.
that way you always know all details about environment.
Other config properties are shared across environments.
But how do you still have an config/environment.js after âember buildâ ? When I do ember build everything gets mashed up in a meta tag in index.html.
Could you provide me with a small snipped of how you achieve dynamic config loading ?
@John are you saying you only want ember build to be run once to build 3 different versions of the app? As far as Iâm aware this is not possible. Ember CLI does significantly different things to a prod build, for example, vs a dev build. The built assets will turn out completely different between the two environments so itâs not as simple as just changing the environment config.
@dknutsen Yes, we only wish to âember buildâ once since the code does no change, only the properties (api url etcâŚ) do. So the idea would be to have a kind of pipeline
build the app
ZIP it and store it somewhere
deploy to DEV
deploy to QA
deploy to PRE-PROD
deploy to PROD
the only difference from 3) to 6) is the config file that changes that we would place it âsomewhereâ in the app and that is loaded at runtime.
We didnât know ember does something different when using ember build -prod vs ember build -dev. If indeed it does something completely different I guess in that case we can drop our idea of a one time build
Yeah I see what youâre saying, definitely donât think itâs possible. For starters I know a prod build will fingerprint everything, minify it, and do some other fancy smashing and munging. That doesnât happen with dev builds, and doesnât happen with custom environments (our company has âwhitelabeledâ builds so even our âotherâ production builds arenât the same as our main âproductionâ build). And then if you throw in addons that use hooks for prod builds only (ember test selectors, for example) there are even more differences.
Not sure what your use cases are beyond what youâve described above but I would highly recommend checking out ember-cli-deploy if youâre not already using it. Very extensible deploy pipeline which can do all kinds of neat stuff out of the box with existing plugins, or you can write custom plugins.
As I mentioned before itâs possible and we use one build across different environments.
As @dknutsen mentioned dev and prod builds are different but code base is the same.
In prod build your code gets minified, images could be squashed, etc.
you certainly donât wont either deploy dev build to prod nor do all prod build jobs during development.
So how it looks like, is for development we of course use dev build done during ember serve or ember build.
We use serve, as no need to start other local server.
For all other environments ( test, uat, prod) we use prod build and only deploy zipped package.
Thatâs handled by bamboo (but jenkins could be used as well).
ember-cli has three kinds of builds (dev, test, and prod). Dev is for running locally, test is for running test suites, and prod is for running on an actual website.
That is separate from the question of which website you want to run on.
If you have dev, QA, and production websites, those are still all production builds from ember-cliâs perspective. How you manage separate configuration for each of them is somewhat up to you. My recommendation is to use ember-cli-deploy and create separate deploy targets for each one, so you can run ember deploy qa vs ember deploy production.
Itâs not strictly true that you need to rebuild for every environment. Itâs enough to do one production build and then make your own <meta> configuration for multiple environments (itâs just url-encoded JSON). Thatâs why we put configuration in <meta> by default instead of compiling it into the Javascript â it makes it easier to swap it out if you want to.