ionic-team / capacitor

Build cross-platform Native Progressive Web Apps for iOS, Android, and the Web ⚡️
https://capacitorjs.com
MIT License
12.17k stars 1.01k forks source link

feat: set config file through command line, with `--config` #4182

Open adamdbradley opened 3 years ago

adamdbradley commented 3 years ago

Feature Request

Description

Be able to state which config file to use through the command line. This would be useful when having a dev config and production config, then the build scripts can decide which file to use. Similar concept to configuring dev and prod builds with webpack, rollup, angular, etc. If there's no --config or -c flag then fallback to the original path of finding the config file.

Similar Concepts

Alternatives

How Capacitor config actually works is pretty unique in how it copies the built config files to the native builds. That process may offer a better way to do this.

Additional Context

During development, I'd like to set the dev server's localhost path within server.url, but do not need that config for production.

jcesarmobile commented 3 years ago

Something to have in mind, appflow relies on the existing config file names to check if it’s a capacitor project, so if we allow any name we should provide some way for indicating it’s a capacitor project.

ibrahimawadhamid commented 3 years ago

+1 for custom config file

richard-flosi commented 2 years ago

As a work around you can define a capacitor.config.ts or capacitor.config.js file to programmatically build your config based on Environment Variables.

Noste commented 8 months ago

This would also be very useful in the context of Monorepos where the node_modules are in the root folder and the capacitor.config.ts file is located in a sub directory.