Angular 9 Build Bundle目录 [英] Angular 9 Build Bundle Directory
问题描述
我试图设置Angular 9构建,以将样式和脚本包输出到特定的子文件夹(例如"app")中,并让index.html在其对包的引用中使用这些路径.我发现了一些旧的和有冲突的信息,但是还没有发现. Angular CLI已被频繁且重大地更新,并且方法可能已更改.我想在angular.json
中执行此操作,而不是使用任何类型的postbuild脚本,CLI标志等来执行此操作,以便可以在源代码中清晰地进行维护.
I'm trying to set up my Angular 9 build to output style and script bundles into a specific subfolder (e.g. "app") and have index.html use those paths in its references to the bundles. I found some old and some conflicting information on this but nothing quite hit the spot yet. The Angular CLI has been updated frequently and significantly, and approaches may have changed. I want to do this within angular.json
, not with any type of a postbuild script, a CLI flag, etc., so that I can maintain this cleanly within the source code.
任何帮助将不胜感激!谢谢!
Any help would be appreciated! Thank you!
推荐答案
在您的angular.json
修改以下构建配置中,它将把已翻译的打字稿文件移动到static
文件夹中.
In your angular.json
modify the following build configuration it will move the transpiled typescript files to the static
folder.
"outputPath": "dist/<project>/static",
"deployUrl": "static/",
"index": {
"input": "src/index.html",
"output": "../index.html"
},
对于资产结构,请使用以下配置
For Assets structuring use the following configuration
"assets": [
{
"glob": "**/*",
"input": "src/assets/",
"output": "./../assets/"
},
{
"glob": "favicon.ico",
"input": "src/",
"output": "./../"
}
],
这篇关于Angular 9 Build Bundle目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!