Angular 5 - 动态基引用导致重复加载包|块 [英] Angular 5 - Dynamic base reference is causing duplicate loading of bundles|chunks
问题描述
我在项目中使用 Angular 5.2 版本.我在 index.html 中动态设置基本引用以满足不同客户端的不同 URL.
应用主页网址如下所示:-
http://example.com/client1/app/loginhttp://example.com/client2/app/loginhttp://example.com/client3/app/login
client1、client2 等是 IIS 中的虚拟目录.
当我在浏览器中运行应用程序时,我可以从检查窗口看到重复的块正在加载并导致应用程序页面变慢.
我观察到重复块的 Web 请求 url 的一件事.假设 script.xxxxxxxxxxxxxxxxxxxxxx.bundles.css.
第一个网络请求:-
Index.html 在我的项目中看起来像这样 :-
<html lang="zh-cn"><头><meta charset="utf-8"><title>网页</title><link href="/assets/Images/favicon.ico" rel="shortcut icon" type="image/x-icon"><base id="baseHref" href="/"><脚本>(功能 () {if (window.location.hostname !== 'localhost') document.getElementById('baseHref').href = "/" + window.location.pathname.split('/')[1] + "/";})();<meta name="viewport" content="width=device-width, initial-scale=1">头部><身体><app-root></app-root>