single-spa demo single-spa simple-single-spa-webpack-example
A demo is live on surge.sh.
The npm project is based on single-spa-angular-cli
A demo is live on placeme.io (comming soon).
git clone git@github.com:PlaceMe-SAS/single-spa-angular-cli-examples.git
cd single-spa-angular-cli-examples
npm install -g @angular/cli
npm install
npm run ng:build
npm start
That's all!
npm run ng:lint
npm run ng:test
That's all!
cd apps/home
ng serve --port=4201
// webpack.config.js
const devApplications = {
//menu: 'http://localhost:4200',
home: 'http://localhost:4201',
//app1: 'http://localhost:4202',
//help: 'http://localhost:4203'
};
...
cd apps/home
ng build --prod -op ../../build/home
npm run ng:build
npm run build (comming soon)
cd apps
ng new app1 --prefix=app1
cd app1
ng serve --port=4202
// app1/src/polyfills.ts
// Comment zone.js, it is globaly imported by the portal
// import 'zone.js/dist/zone'; // Included with Angular CLI.
<!-- app1/src/index.html -->
<app1-root></app1-root>
<script src="https://cdnjs.cloudflare.com/ajax/libs/zone.js/0.8.19/zone.js"></script>
</body>
// apps/app1/src/main.ts
import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { platformSingleSpa } from 'single-spa-angular-cli';
import { AppModule } from './app/app.module';
import { environment } from './environments/environment';
if (environment.production) {
enableProdMode();
}
platformSingleSpa.mount('app1').subscribe(({ props, attachUnmount }) => {
platformBrowserDynamic().bootstrapModule(AppModule).then((module) => {
attachUnmount(module);
// Do something with props if you want
// Ex : module.instance.setSomething(...)
});
});
// portal/applications.config.json
[
{
"name": "menu",
"selector": "menu-root",
"baseHref": "/menu",
"matchRoute": "/**"
},
{
"name": "home",
"selector": "home-root",
"baseHref": "/home",
"matchRoute": "/home/",
"isDefaultApp": true
},
{
"name": "app1",
"selector": "app1-root",
"baseHref": "/app1",
"matchRoute": "/app1/"
},
{
"name": "help",
"selector": "help-root",
"baseHref": "/help",
"matchRoute": "help=open"
}
]