如何更改 angular-cli css 包生成的资源路径?

How change paths to resources in generating by angular-cli css bundle?

描述

在我们基于 webpack 的 angular 项目中,我们使用下一个部署管道:
1.生成所有静态资源到static文件夹
2.生成索引html
3.部署静态资源到"Static server"(S3 bucket)
4. 将 index.html 部署到 "Main server"

Dist 文件夹如下所示:

dist  
--static  
----anivers-bold.eot  
----logo.svg  
----styles.bundle.css  
----code.bundle.js  
--index.html  

index.html 中的资源链接如下所示:
<script src="http://127.0.0.1:4200/code.bundle.js"></script>

所以,现在我生成了与 index.html 相似的结构,但是 styles.bundle.css 中的链接到字体和图像设置不正确。
当前:src: url('anivers-bold.eot');
预计:src: url('http://127.0.0.1:4200/anivers-bold.eot');

有人知道我如何更改 angular-cli css 包生成的资源路径吗?

我的尝试

您可以在 test repository 中找到测试应用。使用 ng build 进行测试构建

我深入研究 angular-cli,发现 postcss 插件,处理资源:node_modules\@angular-devkit\build-angular\src\angular-cli-files\plugins\postcss-cli-resources.js

我尝试使用 resourcesOutputPath 参数,但它只生成目录。 我也尝试在 base 标签中更改 href,但在这种情况下 angular 路由器中断。

我找到了下一个解决方案:
在 .css 文件中,这是从远程服务器获取的,从该服务器请求的资源
因此,我们需要在全局样式中提取带有资源(背景-url、字体)的样式,所有样式都会 waork