Yago Lopez
Yago Lopez

Reputation: 79

How to include assets in a library project created with the Angular CLI?

I am developing a library using Angular CLI. In a normal project you have an assets directory where include images, svg and other files that will be distributed for production in dist folder. How can I include assets files for distribution in a library project created with the CLI? Thanks.

Upvotes: 2

Views: 4077

Answers (1)

Vivek Kumar
Vivek Kumar

Reputation: 5050

I use npm install lifecycle hooks. created a postinstall.js containing the copy command for pasting it the directory where I want these assets to be placed in the angular application when someone installs my lib.

You also need to modify the np-packgr configuration "keepLifecycleScripts": true

"scripts": {
        "postinstall": "node post-install.js"
    },
    "peerDependencies": {},
    "ngPackage": {
        "$schema": "../node_modules/ng-packagr/ng-package.schema.json",
        "dest": "../../../../dist",
        "workingDirectory": ".ng_build",
        "lib": {
            "entryFile": "./index.ts",
            "externals": {}
        },
        "keepLifecycleScripts": true
    }

Upvotes: 1

Related Questions