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/lib1 using ng generate library @acme/lib1
  • Create assets folder under projects/acme/lib1/assets and add images
  • Add a "projects" -> "@acme/lib1" -> "architect" -> "build" -> "options" -> "assets" key to the library's config within angular.json file.
  • Build library using ng build @acme/lib1
  • Fail error should show and none of the assets will be copied to dist folder.

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)

原文地址:https://github.com/angular/angular-cli/issues/11071

最新文章

  1. sql中case when语句的使用-来自网摘文章
  2. 使用wcf服务捕捉到“POST http://yourIP/WCFService.svc 405 (Method Not Allowed) ”错误!
  3. 20160205 - Windows 10 家庭版没有组策略
  4. angular 国际化
  5. http请求利器: 今天配置出了RESTClient,用MAVEN构建了UI运行包
  6. javascript grunt安装和使用
  7. Android-关于android:scrollbarStyle属性
  8. css3 calc():css简单的数学运算-加减乘除
  9. Nginx、LVS及HAProxy负载均衡软件的优缺点详解
  10. file的getPath getAbsolutePath和getCanonicalPath的区别
  11. 深入理解Java的接口和抽象类 _摘抄
  12. osg学习笔记3 简单几何模型
  13. 运用linq查找所有重复的元素
  14. HTML标签练习
  15. 添加MySql Metat Database 信息
  16. 嗯,这个BLOG其实是个更新服务器
  17. 虚拟机上的centos7链接不上网络: activation of network connection failed
  18. World Finals 2018 感想
  19. sql_calc_found_rows原理
  20. day25 上山练习 计算圆练习

热门文章

  1. struts数据回显
  2. 溢出overflow: hidden
  3. JMeter4.0分布式调度压测部署
  4. log4j日志配置文件
  5. Ceph 分布式存储架构解析与工作原理
  6. Pyqt5-QtWidget的使用
  7. 2019.12.24 【ABAP随笔】smartforms 打印及PDF转化
  8. Qt QLabel添加cliked事件
  9. WDM-波分复用
  10. 服务器iptables规则记录