ng build将文件导出到dist文件夹,如下所示
index.html
main.bundle.js
styles.bundle.js
...
Run Code Online (Sandbox Code Playgroud)
我希望脚本在子文件夹中
*index.html
scripts/main.bundle.js
scripts/styles.bundle.js
...*
Run Code Online (Sandbox Code Playgroud)
我该怎么做?
我在 Iframe 中使用我的 Angular 应用程序,并且我希望能够在执行构建(ng build)后更改 index.html 中的 javascript 文件的路径。
这是我用来构建我的 Angular 应用程序的命令:
npm run env && ng build --aot --prod --environment=prod
Run Code Online (Sandbox Code Playgroud)
完成后,在我的 dist 文件夹中我有这棵树:
index.html
inline.318b50c57b4eba3d437b.bundle.js
main.d83bd9b8af8c676f706b.bundle.js
and etc
Run Code Online (Sandbox Code Playgroud)
查看index.html我们可以看到以下内容:
<body>
...
<script type="text/javascript" src="inline.318b50c57b4eba3d437b.bundle.js"></script>
<script type="text/javascript" src="polyfills.5a5809ec73e38d8a32d3.bundle.js"></script>
<script type="text/javascript" src="scripts.7b67fa96a25429619fd6.bundle.js"></script>
<script type="text/javascript" src="main.d83bd9b8af8c676f706b.bundle.js"></script>
</body>
Run Code Online (Sandbox Code Playgroud)
我想以某种方式更改构建命令,也许有一个我没有看到的标志或任何其他方法来生成具有不同路径的 javascript 文件的 index.html ,如下所示:
<body>
...
<script type="text/javascript" src="PathBefore/inline.318b50c57b4eba3d437b.bundle.js"></script>
<script type="text/javascript" src="PathBefore/polyfills.5a5809ec73e38d8a32d3.bundle.js"></script>
<script type="text/javascript" src="PathBefore/scripts.7b67fa96a25429619fd6.bundle.js"></script>
<script type="text/javascript" src="PathBefore/main.d83bd9b8af8c676f706b.bundle.js"></script>
</body>
Run Code Online (Sandbox Code Playgroud)