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

how to avoid multiple angular.json #85

Closed
vance opened this issue Feb 21, 2019 · 7 comments
Closed

how to avoid multiple angular.json #85

vance opened this issue Feb 21, 2019 · 7 comments

Comments

@vance
Copy link

vance commented Feb 21, 2019

We are running into a situation where it doesn't make sense to have multiple angular.json in a mono repo since we have so many libs. We were able to do most ionic commands from the root, however, when it comes time to run a ionic build app-name android it fails because it can't find the root angular.json of course. Any type of architectural suggestions would help.

@vance
Copy link
Author

vance commented Feb 21, 2019

One idea is to move the ionic config out to the root, but that will likely make it create iOS and android at the root, and plugins will have to be installed at the root as well.

@NathanWalker
Copy link
Member

The ideal really is to manage all those things at the root staying true to the Monorepo style. This is the same for {N} apps as well.

With Ionic this would be more possible to manage the angular.json and everything else at root but I think you’d wanna keep the build artifacts in with the apps or could simple all be built in a dist folder at root which would have app builds organized by name there which would work well.

@vance
Copy link
Author

vance commented Mar 6, 2019

the problem remains though: having the angular.json outside the ionic app at the root, none of the cordova commands work because it expects the angular.json to be in the app, and not up a directory. I can't build the final APK or iOS binary.

> ng run app:ionic-cordova-build --platform=ios
Project 'app' could not be found in workspace.
Error: Project 'app' could not be found in workspace.

but of course if you run the commands at the root it says must be run inside an ionic/cordova project If I could pass options to ng build to specify a project, this might work, but it still has the problem of not being able to specify a path for angular.json. But, you can't pass flags.... ionic-team/ionic-cli#3602

@vance
Copy link
Author

vance commented Mar 6, 2019

so my only two really bad options are :

  1. write a parser to copy angular json into ionic at build time, and have it "smartly" change all the paths (so ugly and hard).
  2. move all the ionic configuration/project files up to the root of the xplat project, also so ugly.

@NathanWalker
Copy link
Member

You’ll probably wanna do what we do for most configurations which is utilize npm scripts to traverse into the app directory to issue the command. That ultimately gives you the convenience of running everything in your workspace from the root while avoiding any crazy config copying.

When I have time I’ll investigate some other options but that’s what I recommend as being the easiest.

Ie, see the other ionic run commands in root package which xplat adds.

@vance
Copy link
Author

vance commented Mar 18, 2019

So, the workaround I settled on was to skip the ionic tools and build directly with xcode+fastlane+gradle. Basically doing the cap add and ng build and cap.copy commands per usual, but building the app with standard tools. The loss here is that the ionic toolset is required for live reload/HMR which would be nice to have. It could be a feature request into ionic to play better inside of nx-workspace style apps by providing a config option for where the angular.json is...

The problem is that ionic build commands wrap ng build. Even with command traversing, it just would not accept the fact that angular.json lived outside the project directory.

@NathanWalker
Copy link
Member

ionic apps no longer have a dupe angular.json and instead use workspace json in v8.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants