ng build --prod --base-href /gi-new --deploy-url /gi-new
我将 Angular 5 应用程序部署到 Windows 机器上的共享 IIS 服务器
我已将我的 dist 文件夹的内容上传到 http://192.168.10.181/gi-new
我的应用程序运行但 Assets 中的图标没有选择正确的路径,因此它们没有显示在网页上。
他们使用 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"
}]
条目在 应用组件
constructor(iconRegistry: MatIconRegistry, sanitizer: DomSanitizer) {
iconRegistry.addSvgIconSetInNamespace
( "action", sanitizer.bypassSecurityTrustResourceUrl("assets/svg-icons/svg-sprite-action.svg"));
我怎样才能克服这个问题?
最佳答案
我遇到了同样的问题,我们需要手动为所有图标或 .gif、.jpg 提供正确的路径,无论它们来自生产模式下远程位置的捆绑文件中的 Assets 文件夹。
例如,如果您有类似 https://ip_address_name/gi-new 的路径,您需要在生产捆绑文件中的任何地方添加 (/gi-new/assets/your_icon_name)。
这是解决此特定问题的一种方法。
关于angular - ng build --prod --base-href,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47685936/