-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Multi-app projects config #691
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
Comments
Question ??? |
Hello Kevin, could you send a configuration as an example? Is there any documentation on this? How would you configure the Capacitor for each project? Ionic and Angular use an extra configuration file at the root of each project. I think that capacitor should have too. |
@GuilhermeBCC Putting multiple Capacitor configurations into a single file is a good feature request for some point in the future, but not particularly necessary to get a good experience in Ionic CLI projects. For Cordova, which requires a single |
@GuilhermeBCC any news on this request? As described on #342 (comment) I think it could be really useful to switch quickly between environments. |
@GuilhermeBCC Yep, this should be ready to go for Ionic apps: https://beta.ionicframework.com/docs/cli/configuration#multi-app It's not a super smooth process yet, but hopefully it's usable 😄 But, again, I doubt this feature will make it into Capacitor itself. |
https://beta.ionicframework.com/docs/cli/configuration/#adding-an-app This approach has a lot of problems. In fact using this you are not creating a project in monorepo but rather a standard project in the wrong place. The project is not added to ionic.config.json neither the angular.json and the project does not extend tsconfig.json from root . |
@GuilhermeBCC Please create an issue in the Ionic CLI repo and we can discuss. |
@dwieeb I think I do not need to, since Ionic 4 are just web components. I do not think there's a need for that anymore. Monorepo is already in Angular. I'd like to test Capacitor or Cordova support (for Monorepo). I saw that the issue was closed. Is there already a way to do this? |
Knowing better the capacitor I see that there is no need for this feature so I am closing this issue. For those who arrive here I leave my conclusion. Capacitor is great. In fact it is the differential of the original Ionic3 framework. Ionic3 (great) was divided into Ionic 4 (cool) and Capacitor (great). To work with Monorepo:
Very easy. Thanks @dwieeb for your time and patience |
@GuilhermeBCC I just found that it's possible! With this config:
and having Awesome stuff! |
@GuilhermeBCC while capacitor can work with multi-project repo's it is a bit cumbersome to set up and requires the plugin to be installed via npm at both the root and app levels otherwise plugins will not be automatically imported into the native app. This voids some of the benefits of the monorepo approach. It would be great if capacitor supported the --project and then searched root node_modules folder for plugins to import into that native project. Alternatively the apps/app/capacitor.config.json could be used to specify which node_modules folder to search for plugins. |
This is not easy. This is incredibly inefficient approach. Moreover, it completely defeats the whole purpose of mono-repos. I don't want to manage packages all around my repository, I want to have them centralized... |
@dwieeb Following on from what @jiriKralovec has said, Nx Workspaces provides a monorepo solution that does not place a package.json within the app folder. Due to this we get the following error:
When we run ionic capacitor commands in a multi-app ionic project with config such as: {
"defaultProject": "test-mobile-poc",
"projects": {
"test-mobile-poc": {
"name": "My App",
"integrations": {
"capacitor": {}
},
"type": "angular",
"root": "apps/test-mobile-poc"
}
}
} Are there any properties we need to add to either the {
"appId": "io.ionic.starter",
"appName": "My App",
"bundledWebRuntime": false,
"npmClient": "npm",
"webDir": "www",
"cordova": {}
} If there is additional work required to allow this to work, I'll gladly open a PR for it if I can figure it out. EDIT:
|
Not the best way, but a 'fix' to make capacitor work in a monorepo (I'm using Nx):
That's it for the install process! When you want to run the app you'll have to:
Hope this helps! |
@mhartington @mlynch ; I'll try to make some time this weekend and create a PR with support for monorepos with the previous steps. |
@eduardoRoth I managed to get this set up in Nx with the capacitor deps at the root package JSON. I did have to create a package.json in the app-specif directory, however, I only needed the following: {
"name": "my app"
} Although the capacitor config and all cap commands must be run within that app directory also. |
@Coly010 , if I don't install capacitor in the local folder, I get this error: Probably you have capacitor installed globally. |
Following @matheo comment, you can use This is the structure of my project (created a new one) ionic.config.json file
You'll need to install capacitor as usual: Then run It'll create the Update Run Then you can Although, this creates a root Edit: I'm not even sure that the |
@eduardoRoth Yes, double checked my CD pipeline. Not installing the cap CLI globally, but I am using Also, yes the multi-app setup works for a root ionic.config.json but I had to drop the capacitor.config.json into the local app folder |
Hey folks! I just tried to setup a mono repo project and when it comes to capacitor, my approach fails. I had the following project structure: -myMonoRepoProject
The issue here is, that I had to create a package.json file with the @capacitor/cli devdependency inside the myIonicProject - folder. When I built the myIonicProject with the package.json, my build fails because of a conflict in of the rxjs library @capacitor/cli uses (conflicting with the rxjs lib in the node_modules of the root myMonoRepoProject). Without the package.json inside my myIonicProject the build is fine. Any ideas how to solve this? Is the capacitor-cli going to support mono-repos in the future? |
Apparently, the Ionic Angular monorepos with NX publication and the Y @nxtend/capacitor were a success, as many developers are trying to move their projects to Monorepos workspaces. For example, I am trying to get the plugin to work:
in an ionic-angular project inside an Nx workspace:
and I had patched it by specifying the capacitor.config.json file location, but when developers work with multiple ionic projects. How are we going to patch it? This has led me to think that maybe Capacitor needs to rethink the way to integrate the multi projects (Monorepos) feature to the Capacitor workflow since the current way forces us to have a node_modules folder inside our project and that breaks the monkey repo approach. |
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. |
Feature request
Please add support for multiple projects in angular
Ionic is adding
ionic-team/ionic-cli#3281
Expected result:
npx cap add android --project=app2
npx cap update --project=app2
The text was updated successfully, but these errors were encountered: