Method 1 - Using single-spa-layout
Check out the following link for more information on utilizing single-spa-layout:
Method 2 - Integration within your loading function
import { registerApplication } from 'single-spa';
registerApplication({
name: "app1",
app: loadApp1,
activeWhen: '/'
})
function loadApp1() {
return Promise.resolve().then(() => {
placeLoader()
return System.import('app1')
}).then(app => {
removeLoader()
return app;
})
}
function placeLoader() {
document.body.appendChild(
Object.assign(document.createElement('img'), {
id: 'single-spa-loader',
src: "loading.gif"
})
})
}
function removeLoader() {
document.getElementById('single-spa-loader').remove()
}