Angular: files are not copied to assets folder during build

Viewed 40

I need some files to be copied from node_modules folder to /scr/assets during local build:
I added the following to package.json:

"start": "npm run copy-assets && npm run ng-high-memory -- serve",
"copy-assets": "copy node_modules/ngx-extended-pdf-viewer/assets/images src/assets/images"

npm start runs without errors but nothing is copied to src/assets/images. What did I miss? Any help is appreciated. I have Angular 13, node 16.10.0.

1 Answers

You can specify in your angular.json which assets from node_modules will be copied to your assets.

Under "architect" --> "build", for example:

"styles": [
    "node_modules/bootstrap/dist/css/bootstrap.css",
    "src/styles.css"
],

or:

"assets": [
    "src/favicon.ico",
    "src/assets",
    {
        "glob": "*.svg",
        "input": "./node_modules/bootstrap-icons/icons/",
        "output": "/assets/img/"
    }
],
Related