How do we exlude some folder in the root src folde

2019-07-24 20:03发布

问题:

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

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"
        }
    }],

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

回答1:

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
  ]
}


回答2:

This configuration is in 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"
    ]
}