运行ng build时,我们如何在root src文件夹中排除某个文件夹

时间:2017-06-12 07:58:11

标签: angular angular-cli

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

但是我们如何排除root中指定的src内的一些文件夹?

"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" ]之类的内容,但我找不到任何同意的解决方案。

2 个答案:

答案 0 :(得分:5)

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

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

答案 1 :(得分:0)

此配置位于tsconfig-json https://www.typescriptlang.org/docs/handbook/tsconfig-json.html

{
    "compilerOptions": {
        "module": "system",
        "noImplicitAny": true,
        "removeComments": true,
        "preserveConstEnums": true,
        "outFile": "../../built/local/tsc.js",
        "sourceMap": true
    },
    "include": [
        "src/**/*"
    ],
    "exclude": [
        "node_modules",
        "**/*.spec.ts"
    ]
}