忽略ng build --prod中的`assets`文件夹

Gag*_*ags 4 angular

我不想在其中包含assets文件夹

ng build --prod

但是assets我运行时文件夹应该可用

ng serve
Run Code Online (Sandbox Code Playgroud)

我试着写如下:

apps:[
   exclude: ["assets"]
]
Run Code Online (Sandbox Code Playgroud)

但这没有用。也尝试了以下解决方案

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

但是,这些都不起作用。任何帮助将不胜感激。

小智 5

我有一个非常相似的场景,因为在使用aot进行构建时我不想复制资产文件夹。找到这篇文章后,我最终在.angular-cli.json中复制了我的应用程序配置,每个都有其唯一的名称(在我的情况下为devAppaotApp),如下所示:

"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"project": {
    "name": "my-project"
},
"apps": [
    {
        "name": "devApp",
        "root": "src",
        "outDir": "wwwroot",
        "assets": [
            "assets",
            "favicon.ico"
        ],
        "index": "index.html",
        "main": "main.ts",
        "polyfills": "polyfills.ts",
        "test": "test.ts",
        "tsconfig": "tsconfig.app.json",
        "testTsconfig": "tsconfig.spec.json",
        "prefix": "app",
        "styles": [
            "styles.scss"
        ],
        "scripts": [
        ],
        "environmentSource": "environments/environment.ts",
        "environments": {
            "dev": "environments/environment.ts",
            "prod": "environments/environment.prod.ts"
        }
    }
    ,
    {
        "name": "aotApp",
        "root": "src",
        "outDir": "wwwroot",
        "assets": [
        ],
        "index": "index.html",
        "main": "main.ts",
        "polyfills": "polyfills.ts",
        "test": "test.ts",
        "tsconfig": "tsconfig.app.json",
        "testTsconfig": "tsconfig.spec.json",
        "prefix": "app",
        "styles": [
            "styles.scss"
        ],
        "scripts": [
        ],
        "environmentSource": "environments/environment.ts",
        "environments": {
            "dev": "environments/environment.ts",
            "prod": "environments/environment.prod.ts"
        }
    }
],
--- and then the rest of the configuration
Run Code Online (Sandbox Code Playgroud)

所以...我要开发ng serve --app devApp(尽管似乎ng serve也可以),当我需要生成用于生产的包时,我运行ng build --app aotApp --prod