fix svelte skeleton

This commit is contained in:
Nacho Codoñer
2025-08-22 17:09:19 +02:00
parent 40b97e5e09
commit 47ceed02ce

View File

@@ -1,9 +1,26 @@
import { Meteor } from 'meteor/meteor';
import App from '../imports/ui/App.svelte';
import { mount, unmount } from 'svelte';
let app; // will hold the mounted instance
Meteor.startup(() => {
new App({
target: document.getElementById('app')
});
});
const target = document.getElementById('app');
// (Re)mount
app = mount(App, { target });
// Clean up on HMR so we don't double-mount
if (import.meta.webpackHot) {
import.meta.webpackHot.accept();
import.meta.webpackHot.dispose(() => {
if (app) {
// pass the instance you got from mount()
unmount(app, { outro: false }); // set outro:true if you want transitions
app = null;
}
// optional: clear target to be extra safe
target.innerHTML = '';
});
}
});