我有一个文件夹"project/src/Backend/*"
,我想从ng serve
中排除。
Angular版本是6.1.x。
我已经尝试过的是在 tsconfig.app.json , tsconfig.json 和 angular.json 中添加一些排除项。
>我在www上找到的每个解决方案都不适合我。
angular.json
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"piloto": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"prefix": "app",
"schematics": {},
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/piloto",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.app.json",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"src/styles.css",
"src/theme.scss"
],
"scripts": [
"node_modules/jquery/dist/jquery.min.js"
]
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "piloto:build",
},
"configurations": {
"production": {
"browserTarget": "piloto:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "piloto:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.spec.json",
"karmaConfig": "src/karma.conf.js",
"styles": [
"src/styles.css"
],
"scripts": [],
"assets": [
"src/favicon.ico",
"src/assets"
]
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"src/tsconfig.app.json",
"src/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**",
"**/Backend/**"
]
}
}
}
},
"piloto-e2e": {
"root": "e2e/",
"projectType": "application",
"architect": {
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "e2e/protractor.conf.js",
"devServerTarget": "piloto:serve"
},
"configurations": {
"production": {
"devServerTarget": "piloto:serve:production"
}
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": "e2e/tsconfig.e2e.json",
"exclude": [
"**/node_modules/**"
]
}
}
}
}
},
"defaultProject": "piloto"
}
答案 0 :(得分:1)
事实是,前端的src文件夹中根本不应该有任何后端的东西!
但是,如果您确实需要,请排除src / tsconfig.app.json中的目录,而不要包含angular.json中的目录。
答案 1 :(得分:0)
使用ng serve
,您的项目将在临时开发服务器中运行,而该服务器将不会在生产环境中使用。
构建保护后,仅/assests
中的{project-location}/dist/{project-name}/assets
将被提供。
因此,您不必显式排除其他文件夹。但是您可以将其排除在与tsconfig.json
的源代码集成之外,而这并不是必需的。