防止ng build编辑index.html,Angular 4

防止ng build编辑index.html,Angular 4,angular,typescript,angular-cli,Angular,Typescript,Angular Cli,我正在构建一个Angular(4)项目,在这个项目中,我很少使用ngserve,而是使用ngbuild编译类型脚本并捆绑js,使用else where调试 ng build谢天谢地向dist目录中的bundles js文件添加了ref 当我执行ng build <script type="text/javascript" src="dist/inline.bundle.js"></script> <script type="text/javascript"

我正在构建一个Angular(4)项目,在这个项目中,我很少使用
ngserve
,而是使用
ngbuild
编译类型脚本并捆绑js,使用else where调试

ng build
谢天谢地向
dist
目录中的bundles js文件添加了ref

当我执行
ng build

  <script type="text/javascript" src="dist/inline.bundle.js"></script>
  <script type="text/javascript" src="dist/polyfills.bundle.js"></script>
  <script type="text/javascript" src="dist/styles.bundle.js"></script>
  <script type="text/javascript" src="dist/vendor.bundle.js"></script>
  <script type="text/javascript" src="dist/main.bundle.js"></script>


但这里是不好的部分。每次调用
ng build
时,这些行都会添加到index.html中。有没有办法关闭自动添加html引用的功能。这不是一个大问题,但是如果知道如何在配置中关闭它,那就太好了。

我也遇到了同样的问题
ng build——watch
会创建一个无限循环,因为它不断地重建自己,以响应自己对
index.html的更改


只需将
outdir
更改为
。/dist
并引用该位置中的文件,就可以为我解决问题。

我不知道这一点。为什么不希望添加这些文件?可以尝试在.angular-cli.jsonit中添加“exclude”:[“index.html”]一次,这样做很好。但是每次我调用
ng build
时,它都会添加文件。因此,对于每个构建,我将多次在index.html.odd中包含脚本,但情况不应该如此。我唯一能想到的就是你的输出目录和你的源目录是一样的。在.angular cli.json中,您的“outDir”和“root”是什么?它不应该包含脚本,而应该为您的angular应用程序添加最新的捆绑代码。