Skip to content

Sharing between apps

Chris Clarke edited this page Jul 22, 2019 · 2 revisions

There is a common set of components, models and features within the libs folder which can be called from any app via @picsa/shared. Similarly individual apps can be referenced using similar notation listed in the root and child tsconfig.json files relative to the root baseUrl, i.e.

"baseUrl": ".",
"paths": {
  "@picsa/*": ["libs/*"],
  "@picsa/shared/*": ["libs/*"],
  "@picsa/budget/*": ["apps/budget-tool/*"],

As the monorepo is essentially just a collection of folders, .ts files can also be imported through relative urls even if they are outside the child app directory.

Styles cannot be picked up in this way, and instead need to be included in the angular.json file configuration, e.g. to import the common libs/scss stylesheets you can use

"styles": [
              "apps/budget-tool/src/styles.scss",
              "libs/scss/_index.scss"
            ],

Assets can also be shared from the libs/assets folder by including the glob in angular.json:

"assets": [
  "apps/.../src/favicon.ico",
  "apps/.../src/assets",
  {
    "glob": "**/*",
    "input": "./libs/assets/",
    "output": "./assets"
  }
]
Clone this wiki locally