6

I'm currently working on an Angular 6 project containing multiple libraries built and released using ng-packagr. One of those libraries is a component library. As such, it contains multiple component each of them with their own scss. As part of the build of this library with ng-packagr, the html and scss get inlined (and transpiled to css) which is normal and the expected behaviour.

I know that when building a standard Angular app using the @angular-devkit/build-angular:browser there is a flag extractCss that will create a styles.css file as part of the built app containing all of the styles.

Is there a way to do so using ng-packagr?

ng-package.json:

{
  "$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
  "dest": "../../dist/storager",
  "lib": {
    "umdModuleIds": {
      "@ngrx/effects": "effects",
      "@ng-bootstrap/ng-bootstrap": "ngBootstrap",
      "@ngrx/store": "store",
      "@ngrx/router-store": "fromNgrxRouter",
      "ngrx-store-localstorage": "ngrxStoreLocalstorage",
      "@ng-select/ng-select": "ngSelect",
    },
    "entryFile": "src/public_api.ts",
    "styleIncludePaths": ["../", "../styles/scss"]
  }
}

Build configs for my lib in angular.json:

"build": {
          "builder": "@angular-devkit/build-ng-packagr:build",
          "options": {
            "tsConfig": "projects/storager/tsconfig.lib.json",
            "project": "projects/storager/ng-package.json"
          }
L Tiger
  • 551
  • 2
  • 8

0 Answers0