Skip to content
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

Investigate multiple environment support #3303

Closed
imhoffd opened this issue Jul 20, 2020 · 7 comments
Closed

Investigate multiple environment support #3303

imhoffd opened this issue Jul 20, 2020 · 7 comments
Labels
needs discussion decisions must be made before working on it
Milestone

Comments

@imhoffd
Copy link
Contributor

imhoffd commented Jul 20, 2020

What can Capacitor do to better support multiple environments such as dev, staging, and prod?

Is this a tooling problem or a documentation problem?

ref: #3298

@imhoffd imhoffd added the needs discussion decisions must be made before working on it label Jul 20, 2020
@jcesarmobile
Copy link
Member

It depends on what do you need from the multiple environments, if it's just about the urls the app points to, then that should be a framework thing, not a Capacitor thing, whatever they build for the environment they build would be in the webDir folder and Capacitor will use that.

If they want different bundle identifier/app id, icons, splash, version, etc, then the proper way would be to do it as native projects do, adding a new app target on iOS and a new product flavor (build variant) on Android.

@phal0r
Copy link

phal0r commented Aug 6, 2020

If they want different bundle identifier/app id, icons, splash, version, etc, then the proper way would be to do it as native projects do, adding a new app target on iOS and a new product flavor (build variant) on Android.

@jcesarmobile
So you suggest to completely handle this in the native project setup and not to duplicate project files. Seems like the right approach to me, so it would maybe a good idea to link to a guide in the docs on how to accomplish this. I am currently facing this exact requirement as it comes in really handy to have separate staging and prod app identifier to install them side by side on a single device.

Is building different targets/build variants supported by Appflow?

@imhoffd
Copy link
Contributor Author

imhoffd commented Nov 9, 2020

This issue was created in reference to this discussion:

To my understanding capacitor only supports 1 capacitor.config.js file per project at the moment. I think it would be good to allow us define multiple based on needs of our enviroments i.e. {env}.capacitor.config.js

This has been accomplished in #3756 and will be shipped in Capacitor 3.

@imhoffd imhoffd closed this as completed Nov 9, 2020
@imhoffd imhoffd added this to the 3.0.0 milestone Nov 9, 2020
@jayenashar
Copy link

To my understanding capacitor only supports 1 capacitor.config.js file per project at the moment. I think it would be good to allow us define multiple based on needs of our enviroments i.e. {env}.capacitor.config.js

This has been accomplished in #3756 and will be shipped in Capacitor 3.

is there documentation on this? i can find some docs on capacitor.config.js but not {env}.capacitor.config.js

@buschtoens
Copy link
Contributor

@jayenashar I think the idea is to export different configs from a single capacitor.config.{js,ts} file. You could for instance look at process.env to dynamically generate the right config.

@BleddP
Copy link

BleddP commented Oct 6, 2021

I have a question that is somewhat along the same lines of this topic, but if it deserves its own thread, please let me know and I can open a new issue.

I am working on converting an PWA to a native app with Capacitor and all is working extremely well so far.
However the PWA uses 3 different rest endpoints:

  • localhost --> ourwebsite.test/api/v1/ (set up locally with virtual env)
  • staging --> staging.ourwebsite.com /api/v1/
  • production --> ourwebsite.com/api/v1/

When publishing an android app and uploading the .aab file to google play, I have hardcoded the staging endpoint (as the localhost endpoint obviously wouldn't work). However, if everything is approved, we cannot publish this version to production because it still uses the staging endpoint.

I've read that the best way to manage this is to create two app ID's:

  • com.ourapp.staging
  • com.ourapp.production

But in capacitor.config.json, we can only add one addId.

Is there any way with Capacitor to manage multiple environments?
Or perhaps my question should be is there any way with Google Play and the App Store to check which environment you're currently in and point to the right endpoint dynamically?

@ionitron-bot
Copy link

ionitron-bot bot commented Nov 10, 2022

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Nov 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs discussion decisions must be made before working on it
Projects
None yet
Development

No branches or pull requests

6 participants