进行构建时:
ng build --prod --aot=false
它始终在dist文件夹的index.html中放入<base href>
。有没有办法阻止这个?
答案 0 :(得分:2)
要忘记<base href="/">
上的index.html
,请将其从src/index.html
文件中删除:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>PROJECTNAME</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
...
应该是,然后:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>PROJECTNAME</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
...
ng build
--base-href
标志重要的是要注意ng build
命令has a --base-href
(or --bh
) flag,但它只适用于更改href
属性(如果存在)或添加它(如果它没有&#39;}存在)。 It doesn't allow you to remove it