Multi-app projects config
See original GitHub issueBranching off main issue re: project structure configurability: https://github.com/ionic-team/ionic-cli/issues/2232
We can add support in the Ionic CLI for multi-app projects.
@PoiScript summed it up nicely:
The primary problem is that we can not specify which project to use with ionic-cli
These multi-app projects are typically in the shape of monorepos which have multiple apps and libraries.
- For now, letβs assume all apps are of the same project type:
angular
. This means a sharedangular.json
at the root of the monorepo. - The starters come with an
angular.json
. Not a big deal, but it would need to be deleted
The builders in ng-toolkit were built with Angular 6 tooling, so they support any project structure that the Angular CLI does. The issue is how do we map ionic serve
and related project commands to the requested project such that Ionic and Angular know which project to use.
These commands already have a --project
and --configuration
option to configure which map to configuration within angular.json
. I think all we need to do is read angular.json
, use the key from --project
and find the project root
and then look for ionic.config.json
inside the specified directory.
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (5 by maintainers)
Top GitHub Comments
Working on a proof of concept that should enable support for multi-app workspaces by adding additional configuration to
ionic.config.json
.Constraints:
Case Study: Given the following
ionic.config.json
configuration:And the following extract from
angular.json
We can produce the following directory structure:
When running Ionic commands, the
defaultProject
will be used if it isnβt specified using the--project
flag. The goal is to also make it possible to βswitchβ projects from the CLI viaionic config set defaultProject
or something similar. Note that thedefaultProject
fromangular.json
will not be used.The
root
key is important as it sets the current working directory forcordova
. Capacitor integration here is only illustrative and not part of this proof of concept.With this configuration and directory structure in place, we can now run some commands:
Generate resources for the second app
Add platform for the second app
Build the first app (via ng-toolkit)
And so onβ¦
Existing Apps: The current proposal is strictly opt-in, meaning that existing Ionic apps will continue to work without making any changes to
ionic.config.json
. To make this possible the CLI will look for theprojects
key in the configuration file to determine whether the workspace is set up for single or multiple apps. Migration however should be easy, and new projects could potentially be generated in the newer format.To migrate an existing app to the new configuration schema:
Other considerations:
node_modules
for sharing dependencies. We might need additional package.json files for storing cordova config/dependencies?angular
project types for now.Hi all! π Ionic 4 was released! (see the announcement on our blog)
But, I still have to write some documentation about a multi-app config for CLI 4. We wanted to make the experience for single-app repos solid first. Please be patient, and thanks for subscribing to this issue for updates!
π One bonus: with this, we can also document how to modify
angular.json
to customize project structure! π