当我运行时,ng build
我得到了这个 index.html 文件:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>ApiApp</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
<script type="text/javascript">
const appData = JSON.parse('<%=json%>');
</script>
<app-root></app-root>
<script type="text/javascript" src="runtime.js"></script>
<script type="text/javascript" src="polyfills.js"></script>
<script type="text/javascript" src="styles.js"></script>
<script type="text/javascript" src="vendor.js"></script>
<script type="text/javascript" src="main.js"></script>
</body>
</html>
在构建后使用脚本我会将静态资产推送到某个 CDN,因此我实际上想要生成一个如下所示的 .html 文件:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>ApiApp</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
<script type="text/javascript">
const appData = JSON.parse('<%=json%>');
</script>
<app-root></app-root>
<script type="text/javascript" src="http://cdn.github.com/runtime.js"></script>
<script type="text/javascript" src="http://cdn.github.com/polyfills.js"></script>
<script type="text/javascript" src="http://cdn.github.com/styles.js"></script>
<script type="text/javascript" src="http://cdn.github.com/vendor.js"></script>
<script type="text/javascript" src="http://cdn.github.com/main.js"></script>
</body>
</html>
(我组成了域cdn.github.com
)。所以我可以手动为这些文件生成 url,但我想知道 Angular 是否允许我们以某种方式配置它?