【发布时间】:2018-10-24 09:06:55
【问题描述】:
我有一个 Angular CLI 项目,其中包含两个应用程序。两个应用程序是相同的,但一个应用程序包含构建中的所有文件,另一个需要排除一个模块。
Angular CLI 版本:1.7.4 角度版本:5.2.10
我在 angular-cli.json 文件中添加了两个应用程序,每个应用程序都有一个单独的 ts-config 文件。
"apps": [
{
"name": "app", <---- first app
"root": "src",
"outDir": "/wwwroot",
"assets": [
"assets",
"favicon.ico"
],
"index": "index.html",
"main": "main.ts",
"polyfills": "polyfills.ts",
"test": "test.ts",
"tsconfig": "tsconfig.app.json", <----first TS config
"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": "admin", <---- second app
"root": "src",
"outDir": "/wwwroot",
"assets": [
"assets",
"favicon.ico"
],
"index": "index.html",
"main": "main.ts",
"polyfills": "polyfills.ts",
"test": "test.ts",
"tsconfig": "tsconfig.admin.json", <----- second ts config
"testTsconfig": "tsconfig.spec.json",
"prefix": "app",
"styles": [
"styles.scss"
],
"scripts": [],
"environmentSource": "environments/environment.ts",
"environments": {
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
}
],
“管理员”应用将包含所有文件。 但是,app 数组中的第一个应用程序“app”将排除管理模块。
tsconfig.app.json:
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"baseUrl": "./",
"module": "es2015",
"types": []
},
"exclude": [
"test.ts",
"**/*.spec.ts",
"app/modules/admin/" <----- note: I want this entire directory excluded from the build.
]
}
我在 package.json 文件中设置了两个“ng-build”脚本。
package.json 构建脚本:
"scripts": {
"build-app": "ng build -app app --prod",
"build-admin": "ng build -app admin --prod",
},
为了测试这一点,我在管理模块中更改了一些文本和样式并在本地运行构建。我注意到应用程序的管理版本(应该构建所有文件)可以工作,但是应用程序的“应用程序”版本没有排除管理模块。
有没有人在上面的 sn-ps 中看到任何遗漏/忽略的内容? 有没有人遇到过类似的问题并找到了解决方案?
angular-cli repo 关闭了这个问题,但没有提供修复。 see issue here
【问题讨论】:
标签: angular typescript angular-cli angular5 tsconfig