Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run two separate applications on same port with angular cli

I'd like to run two seperate applications on the same port, one for the 'customers' and the other for the 'administators'. In angular cli you can add multiple apps in the .angular-cli.json but you can't run them at the same time. Does anyone know how I can fix this problem?

like image 804
Swendley Sprott Avatar asked Sep 18 '26 07:09

Swendley Sprott


1 Answers

You can create a new module that includes both of apps.
1. Add a new app to .angular-cli.json:

"apps": [
{
  "name": "all",
  "root": "src",
  "outDir": "dist",
  "assets": [
    "assets",
    "favicon.ico"
  ],
  "index": "index.html",
  "main": "main-all.ts",
  "polyfills": "polyfills.ts",
  "environmentSource": "environments/environment.ts",
  "environments": {
    "dev": "environments/environment.ts",
    "prod": "environments/environment.prod.ts"
  }
}, .......

2. Create main-all.ts file such as you do for other apps. https://github.com/angular/angular-cli/wiki/stories-multiple-apps

3. Create a common module:

@NgModule({
  declarations: [],
  imports: [
    AppModule1,
    AppModule2
  ],
  providers: [],
  bootstrap: [AppComponent1, AppComponent2]
})
export class AppModuleAll {}
like image 147
user3934324 Avatar answered Sep 20 '26 22:09

user3934324



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!