34
loading...
This website collects cookies to deliver better user experience
$ npx create-single-spa
$ npx create-single-spa
$ npx create-single-spa
$ npm i -D @angular-builders/custom-webpack single-spa
root-config
{
"imports": {
"@orgname/root-config": "//localhost:9000/orgname-root-config.js",
"@orgname/react-app": "//localhost:8080/orgname-react-app.js",
"angular-app": "//localhost:4200/main.js"
}
}
<style>
.navbar {
position: fixed;
top: 0;
left: 0;
background-color: #111D4A;
color: white;
font-size: 18px;
font-weight: bold;
width: 100%;
height: 75px;
display: flex;
align-items: center;
}
.navbar ul {
display: flex;
align-items: center;
list-style-type: none;
height: 100%;
}
.navbar li {
padding-right: 24px;
height: 100%;
}
.navbar li:hover {
opacity: 0.8;
}
.navbar a {
text-decoration: none;
color: white;
}
</style>
<div class="navbar">
<ul>
<a onclick="singleSpaNavigate('/react')">
<li>
React
</li>
</a>
<a onclick="singleSpaNavigate('/angular')">
<li>
Angular
</li>
</a>
</ul>
</div>
react-app
angular-app
$ npm start
$ npm start
npm run serve:single-spa:angular-app
When the route changes the new application mounts and the previously loaded application unmounts.