ng build --prod --base-href

Sun*_* K. 6 deployment assets build angular

ng build --prod --base-href/gi-new --deploy-url/gi-new

我将angular 5 app部署到窗口机器上的共享IIS服务器上

我已将我的dist文件夹的内容上传到' http://192.168.10.181/gi-new '

我的应用程序运行,但资产中的图标没有选择正确的路径,因此它们不会显示在网页上.

他们使用的是http://192.168.10.181/assets而不是/ gi-new/assets

angular-cli.json中的条目

"assets":[{"glob":"*.svg","input":"../ node_modules/material-design-icons/sprites/svg-sprite/","output":"assets/svg-icons "}]

AppComponent中的条目

构造函数(iconRegistry:MatIconRegistry,sanitizer:DomSanitizer){iconRegistry.addSvgIconSetInNamespace("action",sanitizer.bypassSecurityTrustResourceUrl("assets/svg-icons/svg-sprite-action.svg"));

我该如何克服这个问题?

Sun*_* K. -1

解决了我自己。仅在环境产品文件中为 baseHref 添加了一个条目,并在“assets/svg-icons”之前添加了值

  • 你能详细说明你的答案吗? (4认同)