Importing CSS from NPM Packages With Angular | Task

Ole Ersoy
Mar - 20  -  1 min

Scenario

We have created a cross project css package @fireflysemantics/css and we want to import it into our Angular project styles.scss file.

Approach

Note the use of ~. It is an alias for node_modules.

@import "~@fireflysemantics/css/index.css"

It's also possible to include it using via angular.json.

In that case it should be added via the styles array.

The styles array ( projects > architect > build > styles looks looks like this with the Angular Material Indigo Pink theme added:

"styles": [
  "./node_modules/@angular/material/prebuilt-themesindigo-pink.css",
  "src/styles.sass"
]