运行 ng build 时,我们如何排除根 src 文件夹中的某个文件夹 [英] How do we exlude some folder in the root src folder when running ng build

查看:46
本文介绍了运行 ng build 时,我们如何排除根 src 文件夹中的某个文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我由 angular-cli 生成的应用程序中,有控制 ng 操作的 angular-cli.json 文件.

In my application generated by angular-cli there is angular-cli.json file which control ng operations.

但是我们如何排除根目录中指定的 src 中的某个文件夹?

But how do we exclude some folder inside src which is specified in the root?

"apps": [{
        "root": "src",
        "outDir": "dist",
        "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.css"
        ],
        "scripts": [],
        "environmentSource": "environments/environment.ts",
        "environments": {
            "dev": "environments/environment.ts",
            "prod": "environments/environment.prod.ts"
        }
    }],

我想添加类似 "exclude": [ "folder_name1", "folder_name1";] 但我找不到任何与此一致的解决方案.

Im thinking to add something like "exclude": [ "folder_name1", "folder_name1" ] but i cannot find any solution that agree in this.

推荐答案

ng-build 会运行 tsc 编译目标文件,可以添加 exclude 设置到 tsconfig.app.json 以排除某些特定文件或文件夹.

ng-build will run tsc to compile target files, you can add exclude settings into tsconfig.app.json to exclude some specific files or folder.

{
  "compilerOptions": {
    ...
  },
  "exclude": [
    "folder"    // example
  ]
}

这篇关于运行 ng build 时,我们如何排除根 src 文件夹中的某个文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆