mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
fix svelte skeleton
This commit is contained in:
@@ -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 = '';
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user