Introduce environment specific configurations for Spartacus deployment on ccv2
See original GitHub issueFor angular developers it’s very common to use the environments file to distinguish different settings for different builds. This is often used for setting up different tokens for different environment. For example to target a different payment system, analytic system, tag manager, etc.
The build on Commerce Cloud is currently always using the production build. With this setup, the environment specific settings are not aligned with the build, as production build is always using the production environment settings.
Different options:
- We align the angular build with the build to ccv2 environments. This would result in specific builds for specific environments. This will make the builds no longer reusable cross environments.
- load environment settings from a file while bootstrapping the app. This would not be recommended for production builds as we introduce a blocking call before we can bootstrap the app (using config initializers)
- bake environment specific variables into UI, similarly to what we’ve done with the
occ-backend-base-url
. We would use backend properties, which gives the advantage of runtime configuration over build time configuration.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:14
- Comments:44 (11 by maintainers)
Top Results From Across the Web
Deploy spartacus on Cloud - SAP Community
It's using the prod env file by default. For more details please see Introduce environment specific configurations for Spartacus deployment on ...
Read more >Spartacus: a different configuration per environment on SAP ...
Since Spartacus is based on Angular, we tried the official approach mentioned by SAP that involves creating a different configuration file per ...
Read more >Contributor Setup - Spartacus Documentation - SAP
Configure your back end URL in the projects/storefrontapp/src/environments/environment.ts file. The environment. · There are separate configuration files for B2C ...
Read more >Spartacus CCv2 Build process for multiple enviroments
This is however the only configuration that is environment specific, the ticket referenced by Grin is indeed a feature that we like to...
Read more >Webinar: Spartacus and SAP Commerce Cloud - YouTube
Here is your introduction to SAP's digital commerce platforms with a focus on the features and functions for Business to Consumer (B2C) and ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi Team
Any information on when this may be prioritised? It would be great to just use the single build to deploy to multiple environments. Currently
Thanks, Bala
@simonkeytree - That’s where we disagree and that’s exactly what the immutable webapp approach warns against (Quote: “immutable static assets”, and the production bundle is one of those assets). The same compiled version is deployed everywhere,
index.html
acts as deployment descriptor and “runtime configuration”, in a way. (that’s not that different than using multipleenvironment.ts
)We only(?) need:
env
object by Spartacus<script>
block with pre-definedid
and emptyenv
object in schemasenv
~ EDIT:environment
should read unknown object properties fromwindow.env
(or some other fallback mechanism; not sure about SSR though)env
object (or<script>
) block by accident, the build failsenv
(entrypoint script):index-<environment>.html
with fallback toindex.html
(great idea!)env
object from correctindex.html
, merge object with Service Properties from the CCv2 Cloud Portal and write merged object back toindex.html
index.html
was usedenv
script block/placeholder could not be found inindex.html
env
if it was merged with Service Properties, or info message that no Service Properties required mergingenv
Voila! You have per-environment configuration without an additional request to load the config and you can cache every version of your storefront forever (minus
index.html
, of course.)TBH, I would settle for
index.<environment>.html
support and Service Property injection.