Angular 7-如何分隔不同目录中的文件

mps*_*tos 8 angular-cli angular angular7

我正在将Angular 7应用程序配置为生产环境,并尝试在不同目录中组织文件。

angular.json

            "architect": {
                "build": {
                    "builder": "@angular-devkit/build-angular:browser",
                    "options": {
                        "outputPath": "dist/samsara-ui",
                        "index": "src/index.html",
                        "main": "src/js/main.ts",
                        "polyfills": "src/js/polyfills.ts",
                        "tsConfig": "src/tsconfig.app.json",
                        "assets": [
                            "src/favicon.ico",
                            "src/assets"
                        ],
                        "styles": [
                            "src/styles.css",
                            "src/samsara-theme.scss"
                        ],
                        "scripts": []
                    },
Run Code Online (Sandbox Code Playgroud)

目前,我的目录如下所示:

??? dist
|   ??? <appname>
|   |   ??? assets
|   |   |   ??? icons
|   |   |   ??? images

|   |   |   index.html
|   |   |   *.js (bundled files: runtime.js, polyfills.js, vendor.js, main.js)
|   |   |   *.map
|   |   |   style.css
|   |   |   *.woff, *.woff2, *.tff, *.eot
Run Code Online (Sandbox Code Playgroud)

通过编译,捆绑的javascript文件会在根目录中生成,同时字体文件也会复制到根目录中

我想要:

  1. 指定其他目录以捆绑js文件
  2. 指定字体文件的其他目录。(如果它必须与js文件位于同一目录中,那么没问题,但是很高兴可以有所不同)

结构如下所示:

??? dist
|   ??? <appname>
|   |   ??? assets
|   |   |   ??? icons
|   |   |   ??? images

|   |   |   index.html
|   |   |   style.css

|   |   ??? libs
|   |   |   |   *.js
|   |   |   |   *.map

|   |   ??? fonts
|   |   |   *.woff, *.woff2, *.tff, *.eot
Run Code Online (Sandbox Code Playgroud)

有可能实现这一目标吗?如果是,怎么办?

非常感谢您的帮助。

最好的祝福

Sri*_*kar 4

它不受官方支持,但您可以使用,

--baseHref=baseHref      Base url for the application being built.

--deployUrl=deployUrl    URL where files will be deployed.

--outputPath=outputPath  path for the new output directory
Run Code Online (Sandbox Code Playgroud)

通过组合它们,您可以将 js/map/index.html 文件移动到特定位置并更新 index.html 中的 baseHref 和 url。

更多关于,

https://github.com/angular/angular-cli/issues/10171