我有興趣使用角度cli引導多個應用程序。使用角度cli處理多個應用程序
通過角CLI維基我能找到一個例子 https://github.com/angular/angular-cli/wiki/stories-multiple-apps
而且我發現 https://yakovfain.com/2017/04/06/angular-cli-multiple-apps-in-the-same-project/
我通過角cli.json文件去跑
"apps": [
{
"name": "app1",
"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"
}
},
{
"name": "app2",
"root": "src",
"outDir": "dist2",
"assets": [
"assets",
"favicon.ico"
],
"index": "index.html",
"main": "main2.ts",
"polyfills": "polyfills2.ts",
"test": "test2.ts",
"tsconfig": "tsconfig.app.json",
"testTsconfig": "tsconfig.spec.json",
"prefix": "app2",
"styles": [
"styles.css"
],
"scripts": [],
"environmentSource": "environments/environment.ts",
"environments": {
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
}
],
我能夠得到這個與以下命令運行
ng serve --app 0
ng serve --app 1
我對這種方法的第一個問題是,如果我們列出角度cli中的幾個應用程序將如何保持這種情況?這將得到一些監控和跟蹤。
另外,採用這種方法,你會更好地引導每個main.ts文件中的不同模塊?
我看到完成的第二種方法是在評論中的一個例子。
https://github.com/Farata/angular2typescript/blob/master/Angular4/router-samples/.angular-cli.json。
這是更理想的,雖然我無法複製和識別所有這些應用程序如何共享相同的遠程文件夾和除名稱以外的其他所有內容。
第二種方法分享一切我想知道如何創建大量的模塊和延遲加載它們不同?
我知道這個問題是非常理論化的,但在線資源非常有限,我很想知道其他開發人員如何攻擊此問題。
有沒有辦法如何也測試應用程序彼此分開?我曾發佈過一個問題:[如何在多應用程序項目中單獨測試應用程序?](https://stackoverflow.com/questions/47330580/how-to-test-apps-separately-in-a-multi-app - 項目)在這方面,但沒有答案! –
您可以指定運行每個應用程序的端口並同時運行這兩個應用程序嗎? – Anthony