Upon building & packaging an Angular 6 library, I can't seem to be able to instruct the Angular CLI to copy the library's assets into the dist/assets
folder on every build.
Assuming the project's folder structure is this -
- dist
- e2e
- node_modules
- projects
- lib1
- src
- lib
- assets
- icons
- src
When I run ng build lib1
or ng build lib1 --prod
the assets/icons
folder is not being copied into dist/lib1/assets/icons
.
If I run ng build
then src/assets
(the root src/assets) is being copied but not projects/lib1/assets
.
The angular.json
file contains a reference to "assets": ["src/assets"]
but it won't allow adding the assets
key specifically to the project, only to the main root app. When adding, I get the following error:
Schema validation failed with the following errors: Data path ""
should NOT have additional properties(assets).
I also tried adding the following custom copy rule to the assets to copy the assets to dist/lib instead of to dist/appname:
"assets": [
"src/favicon.ico",
"src/assets",
{ "glob": "**/*", "input": "src/assets/icons", "output": "../lib1/assets/icons" }
],
But I get the following error:
An asset cannot be written to a location outside of the output path.
Is there a built-in way of managing library asset's copy on every build?
UPDATE 06/05/2018
I opened an issue with Angular CLI regarding this but have not heard back yet. Issue #11701
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…