question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support multiple projects, shared libraries

See original GitHub issue

Ionic version: (check one with “x”) [x] 4.x

I’m submitting a … (check one with “x”) [x] feature request

Current behavior:

Thank you for developing nice framework Ionic. As Ionic 4 alpha release, i am considering to managing Ionic project with multiple other angular apps in one repository.

...
node_modules/
projects/
    core/
    ionic-app/
        src/
        ionic.config.json
        ...
    pc/
        src/ 
    electron/
        src/ 
    mobile-web/
        src/ 
tsconfig.json
...

It means that we want to manage Ionic project on ./projects/ionic-app/ folder (not ./src/ folder) However, current state of ionic serve/build only support root folder & src folder access.

Expected behavior:

should support --root options for custom project root folder

ionic serve --root ./projects/ionic-app/ 
ionic build --root ./projects/ionic-app/ 

this feature really helpful for enterprise web services which supports multiple apps (pc, desktop, mobile, app).

Other information:

Ionic info: (run ionic info from a terminal/cmd prompt and paste output below):

latest ionic 4.0.0-alpha.2

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
stupidawesomecommented, May 11, 2018

I had a go at implementing a --project option using 4.0.0-rc.6 and so far it works for my purposes.

Assumptions

  • You want a monorepo using one cordova application as a template to compile multiple angular projects.
  • You’re using prebuild hooks and scripts to manage things like config.xml to change certain settings at build time.

For default behaviour we can use defaultProject in angular.json.

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "",
  "defaultProject": "your-app-name",
  "projects": {
    "your-app-name": { ... },
    "your-other-project": { ... }
  }
  ...
}

For my particular use case I’m using a project structure generated by Nrwl Nx 2.0.0-alpha.2 and merging it with a blank ionic template.

root
-- apps/
---- your-app-name/
---- your-other-app/
-- dist/
---- apps/
------ your-app-name/
------ your-other-app/
-- libs/
-- node_modules/
-- platforms/
-- plugins/
-- resources/
-- tools/
-- www/
---- (copied from dist/apps/<your-app-name> after ng build)
-- angular.json
-- config.xml
-- ionic.config.json
-- nx.json
-- tsconfig.json
-- tsconfig.spec.json
-- tslint.json

The paths to the root of each app are defined at projects.<your-app-name>.root in angular.json so I just read them from disk and extend the angular build options. The only part I’m unsure of is how to pipe the output from dist/apps/<your-app-name> to cordova. The easiest way would be to edit the projects.<your-app-name>.architect.build.options.outputPath entry in angular.json to point to www for each ionic angular app in your workspace. Ideally I just want ionic read from the output path and pass it to cordova but I can’t figure out how to make it do that. As a workaround I added an extra build step so that it copies files from dist/apps/<your-app-name> into www/ where cordova can pick it up. I can just override the --output-path to www/ when using ionic commands.

Now I can run these commands:

ionic serve [--project <your-app-name>]
ionic cordova <cmd> <platform> [--project <your-app-name>]

And I get multiple flavours of a single cordova app 👍 If --project is omitted it builds the defaultProject. For a standard install the default project is called app.

0reactions
imhoffdcommented, Jun 3, 2018

Tracked by https://github.com/ionic-team/ionic-cli/issues/3103 (and https://github.com/ionic-team/ionic-cli/issues/2232)

The ng-toolkit will be a set of builders for the new Angular Architect which Angular CLI 6 uses. More details soon ❤️

Read more comments on GitHub >

github_iconTop Results From Across the Web

Extending with Shared Libraries - Jenkins
A variable defined in a shared library will only show up in Global Variables Reference (under Pipeline Syntax) after Jenkins loads and uses...
Read more >
CMake with 2 Project and a shared Library - Stack Overflow
I have a repository with 2 Projects, which both link a single (self-made) library which is also contained in the repository.
Read more >
A guide to sharing code between projects - Christian Lüdemann
Dublicate code; Shared library; Monorepo; Shared API. All of these have different pros and cons and all can be a good fit for...
Read more >
Managing multiple versions of shared libraries between ...
We can have the libraries available from a common location to be available for all our projects. But how to handle new versions...
Read more >
How to manage library(ies) used by multiple projects?
Based on your description, the common library appears to be a collection of business functionality and utilities common to many of your ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found