Angular 6 CLI does not copy library's assets folder into dist folder.
Versions
Angular CLI: 6.0.7
Node: 9.3.0
OS: darwin x64
Angular: 6.0.3
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router
Package Version
------------------------------------------------------------
@angular-devkit/architect 0.6.7
@angular-devkit/build-angular 0.6.7
@angular-devkit/build-ng-packagr 0.6.7
@angular-devkit/build-optimizer 0.6.7
@angular-devkit/core 0.6.7
@angular-devkit/schematics 0.6.7
@angular/cdk 6.2.0
@angular/cli 6.0.7
@angular/material 6.2.0
@ngtools/json-schema 1.1.0
@ngtools/webpack 6.0.7
@schematics/angular 0.6.7
@schematics/update 0.6.7
ng-packagr 3.0.0
rxjs 6.2.0
typescript 2.7.2
webpack 4.8.3
Repro steps
- Create a library
@acme/lib1usingng generate library @acme/lib1 - Create assets folder under
projects/acme/lib1/assetsand add images - Add a
"projects" -> "@acme/lib1" -> "architect" -> "build" -> "options" -> "assets"key to the library's config withinangular.jsonfile. - Build library using
ng build @acme/lib1 - Fail error should show and none of the assets will be copied to
distfolder.
Observed behavior
Upon building & packaging an Angular 6 library e.g. @acme/lib1 using ng build @acme/lib1, the Angular CLI does not copy the library's assets into the dist/acme/lib1/assets folder. This happens also when using the --prod flag.
The CLI seems to only support copying the root app's assets but not library specific assets.
When trying to add "assets": ["src/assets"] to project @acme/lib1 within angular.json, the following error appears in the command line:
Schema validation failed with the following errors: Data path "" should NOT have additional properties(assets).
When creating the following custom rule to copying the files on ng build:
"assets": [
"src/favicon.ico",
"src/assets",
{ "glob": "**/*", "input": "src/assets", "output": "../acme/lib1/assets/" }
],
I get the following error:
An asset cannot be written to a location outside of the output path.
While it is possible to work around this issue using other command line tools/scripts, it will be more consistent to add support for library's assets copy as well.
Desired behavior
Use Case Very often libraries include image files, icons, css files and other static files which are needed to be distrubted with the package.
What would like to see implemented?
Add ability to define a library specific assets property within angular.json.
Example -
"@acme/lib1": {
"root": "projects/acme/lib1",
"sourceRoot": "projects/acme/lib1/src",
"projectType": "library",
"prefix": "lib",
"architect": {
"build": {
"builder": "@angular-devkit/build-ng-packagr:build",
"options": {
"tsConfig": "projects/acme/lib1/tsconfig.lib.json",
"project": "projects/acme/lib1r/ng-package.json",
"assets": [ // <--------- this is currently not supported
"src/assets"
]
},
...}
What did you expect to see?
Project's specific assets should be copied from projects/acme/lib1/src/assets into dist/acme/lib1/assets.
Mention any other details that might be useful (optional)
Brilliant @klemenoslaj could you share your implementation?
Ck your base directory contain Any special characters
On Mon 16 Sep, 2019, 1:19 PM Bastien Lemaire, [email protected] wrote:
Brilliant @klemenoslaj https://github.com/klemenoslaj could you share your implementation?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/angular/angular-cli/issues/11071?email_source=notifications&email_token=AJWMR66WGH53XVFBYCKK6ODQJ43ARA5CNFSM4FCPTQF2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6YLGKI#issuecomment-531673897, or mute the thread https://github.com/notifications/unsubscribe-auth/AJWMR6Z5N4CH3M4DANDDOFTQJ43ARANCNFSM4FCPTQFQ .
@blemaire in fact I just opened an issue in angular-builders for that very reason. I didn't want to create yet another package, I'd rather contribute there.
I can't understand how, It's been more than one year.
Any news no this?
check your base directory contains special character
Wrong Eg : c:\programfile(S)\test
In above example ( is special character
Working Eg : c:\programfiles\test\
Thanks dhanaraj.k
On Mon, Nov 11, 2019 at 1:28 PM rorry121 [email protected] wrote:
Any news no this?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/angular/angular-cli/issues/11071?email_source=notifications&email_token=AJWMR6ZWIRYMBQETAVAWAKLQTEGB3A5CNFSM4FCPTQF2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEDV66EI#issuecomment-552333073, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJWMR62QZPISAW6P2DT5V2DQTEGB3ANCNFSM4FCPTQFQ .
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.