Added realtime watching capabilites to vite's virtual loaders

This commit is contained in:
Samuel Andert 2023-07-31 09:50:44 +02:00
parent 39071d425e
commit 189857759e
2 changed files with 21 additions and 4 deletions

View File

@ -5,10 +5,10 @@
let isStoreLoaded = false;
$: if (services && services.helloEarthAlert) {
// services.helloEarthAlert.alertMe();
services.helloEarthAlert.alertMe();
}
$: if (services.core) {
// services.core.testAlert();
services.core.testAlert();
}
$: if ($store) isStoreLoaded = true;

View File

@ -46,7 +46,15 @@ export default defineConfig({
return `export default ${JSON.stringify(components)};`;
}
return null;
}
},
handleHotUpdate({ file, server }) { // Add handleHotUpdate to watch for file changes
if (file.startsWith(resolve(__dirname, 'src/lib/components'))) {
server.ws.send({
type: 'full-reload',
path: '*',
});
}
},
},
{
name: 'services-resolver',
@ -70,7 +78,15 @@ export default defineConfig({
return `export default ${JSON.stringify(services)};`;
}
return null;
}
},
handleHotUpdate({ file, server }) { // Add handleHotUpdate to watch for file changes
if (file.startsWith(resolve(__dirname, 'src/lib/services'))) {
server.ws.send({
type: 'full-reload',
path: '*',
});
}
},
},
{
name: 'data-sources-resolver',
@ -102,3 +118,4 @@ export default defineConfig({
}
});