为什么angular library的build不能将assets静态资源打包进去(转)
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)
原文地址:https://github.com/angular/angular-cli/issues/11071
为什么angular library的build不能将assets静态资源打包进去(转)的更多相关文章
- WebStorm 使用webpack打包(build) Vue 静态资源无法访问(路径不对)问题
在WebStorm中使用webpack打包 (命令npm run build) 后生成在项目的dist目录下,在浏览器打开,静态资源js.css等无法加载.因为打包时,资源使用了绝对路径. 解决: 打 ...
- vue 静态资源文件夹src下的assets 和static的区别
static下的静态资源在项目打包的时候,直接在dist文件夹下直接把static文件夹打包进去src下的assets,在打包时,vue是按照模块来引入里面的静态资源,一般使用这种方式
- 使用Angular CLI进行Build (构建) 和 Serve
第一篇文章是: "使用angular cli生成angular5项目" : http://www.cnblogs.com/cgzl/p/8594571.html 第二篇文章是: & ...
- ANGULAR 使用 ng build --prod 编译报内存错误的解决办法
如果你遇到如下的情况 <--- Last few GCs ---> [13724:0000020D39C660D0] 231298 ms: Mark-sweep 1356.3 (1433. ...
- A SIMPLE LIBRARY TO BUILD A DEEP ZOOM IMAGE
My current project requires a lot of work with Deep Zoom images. We recently received some very high ...
- How to add “Maven Managed Dependencies” library in build path eclipse
If you have m2e installed and the project already is a maven project but the maven dependencies are ...
- Android 读取Assets中资源
//读取文件 private static String getFromAssets(Context context, String fileName) { String result = " ...
- 在Android library中不能使用switch-case语句访问资源ID的原因分析及解决方案
转自:http://www.jianshu.com/p/89687f618837 原因分析 当我们在Android依赖库中使用switch-case语句访问资源ID时会报如下图所示的错误,报的错误 ...
- Android ndk下用AssetManager读取assets的资源
转自:http://www.cppblog.com/johndragon/archive/2012/12/28/196754.html 在使用 cocos2dx 在 Android 上进行游戏开发时, ...
随机推荐
- PLSQL报错: ORA-12514:TNS:监听程序当前无法识别连接描述符中请求的服务
一开始吓尿了,以为自己动着什么东西了把数据库玩坏了,谁知道打开服务发现服务没启动........... 我们要确保数据库服务是启动状态
- javascript之DOM(Document Object Model) 文档对象模型
<html> <head> <meta http-equiv="Content-Type" content="text/html; char ...
- 加密算法之 MD5算法
题记:本人自测了很多次,该算法和apache的commons utils包中的MD5算法计算一致 一.针对文件内容生成MD5值 应用场景:针对文件,在传输过程由于网络原因丢帧或者被人别恶意篡改内容,可 ...
- 堆的ptmalloc机制
ptmalloc下堆的分配和回收 ptmalloc内存分配 1) 获取分配区的锁,为了防止多个线程同时访问同一个分配区,在进行分配之前需要取得分配区域的锁.线程先查看线程私有实例中是否已经存在一个分配 ...
- ubuntu快速联网
1:打开ubuntu 2:设置 特殊:red hat设置视频:http://www.jikexueyuan.com/course/1349_3.html?ss=1
- 七十三:flask信号之信号机制和使用场景
若安装flask是未默认安装blinker,则pip install blinker 使用信号分为3步,第一是定义一个信号,第二是监听一个信号,第三是发送一个信号 1.定义信号:定义信号需要使用到bl ...
- Mybatis操作数据时出现:java.sql.SQLSyntaxErrorException: Unknown column 'XXX' in 'field list'
这个错误比较重要,而且很常见,故单独进行说明: Mybatis出现:Unknown column 'xxx' in 'field list' 先来看一下程序的内部: dao.addUser(" ...
- 进程,多进程,进程与程序的区别,程序运行的三种状态,multiprocessing模块中的Process功能,和join函数,和其他属性,僵尸与孤儿进程
1.进程 什么是进程: 一个正在被运行的程序就称之为进程,是程序具体执行的过程,是一种抽象概念,进程来自操作系统 2.多进程 多个正在运行的程序 在python中实现多线程的方法 from mult ...
- read: Connection reset by peer
造成此种问题的原因有多种,目前列下我所遇到过的. 1, sshfs usrname@172.23.65.122:/home/usrname ./122 在ubunutu 里面使用 sshfs 命令 映 ...
- word2010目录和正文分开编页码
最近公司要写文档,老板给了一个范文模板,其中目录和正文的页码就是分开编辑的.上网查了很多资料,基本上都没有附图,通过自己的摸索以后终于实现了.现在我就把实现过程跟截图一并奉上.