ACarr
ACarr

Reputation: 89

Imported style sheets in SCSS file not being packaged with ng-packagr?

I am creating an Angular component library and have packaged the component modules so that they can be NPM installed. Unfortunately, I didn't use the CLI to generate the library, so basically did it the old way before Angular 6 made the update. Anyways, my components work as expected when NPM installed from a different application, however I am having one issue with imported CSS style sheets in one of my component's SCSS file.

At the top of this components' SCSS file, I have the line:

@import '~highlight.js/styles/atom-one-dark.css'

Unfortunately this is not being packaged or compiled or whatever with the component. I am using "npm run packagr" and my ng-package.json looks like the basic:

{
  "$schema": "./node_modules/ng-packagr/ng-package.schema.json",
  "lib": {
    "entryFile": "public_api.ts"
  }
}

Upvotes: 1

Views: 1847

Answers (1)

Alexandra Vorobyeva
Alexandra Vorobyeva

Reputation: 61

We build our library about a year ago and back then the best solution was to copy css files after build

package.json:
"build.lib": "ng build my-library && npm run copy-styles",
"copy-styles": "cpx \"./projects/my-library/src/assets/**/*.*\" \"./dist/my-library/assets/\"",

Upvotes: 2

Related Questions