0

In the latest angular-cli (16.0.2), it defaults to using yarn and pnp. With Yarn PNP the node_modules are done, and the packages remain in their zipped form. This is great, but I am wondering how I might be able to include some assets into my Angular build.

My specific example, is that I need to include pdf.js assets in my angular build. Typically one includes the path in assets element of the angular.json file. However, the assets section doesn't seem to support package names (resolved via pnp) as values. The styles section (used for including style sheets) does seem to support package names via pnp.

"styles": [
              "@angular/material/prebuilt-themes/indigo-pink.css",
              "src/styles.scss"
            ],

You can see that @angular/material is a package path which will be correctly resolved by the build-angular builder (@angular-devkit/build-angular:browser).

For now, the work around is to just unzip the package from the cache into a node modules directly and specify the assets entry as normal, but I am thinking there might be a better way.

...
assets: [ 
{
                "glob": "**/*",
                "input": "node_modules/ng2-pdfjs-viewer/pdfjs",
                "output": "/assets/pdfjs"
              }
]
...

I think ideally, the assets entry as processed by the builder should support assets via pnp packages?

jr.
  • 4,503
  • 7
  • 44
  • 62

0 Answers0