Compare commits

...
Sign in to create a new pull request.

1 commit

Author SHA1 Message Date
Nate Moore
96ec8b8d51 fix: perform HMR updates for non-Astro pages 2022-06-20 14:38:49 -05:00

View file

@ -34,12 +34,24 @@ if (import.meta.hot) {
} }
}); });
} }
function isPage(path: string) {
if (!path.includes('/pages/')) return false;
const parts = path.split('/pages/').slice(1);
let isPrivate = false;
for (const part of parts) {
if (part.startsWith('_')) {
isPrivate = true;
break;
}
}
return !isPrivate;
}
async function updateAll(files: any[]) { async function updateAll(files: any[]) {
let hasAstroUpdate = false; let hasPageUpdate = false;
let styles = []; let styles = [];
for (const file of files) { for (const file of files) {
if (file.acceptedPath.endsWith('.astro')) { if (isPage(file.acceptedPath)) {
hasAstroUpdate = true; hasPageUpdate = true;
continue; continue;
} }
if (file.acceptedPath.includes('svelte&type=style')) { if (file.acceptedPath.includes('svelte&type=style')) {
@ -72,7 +84,7 @@ if (import.meta.hot) {
updateStyle(id, content); updateStyle(id, content);
} }
} }
if (hasAstroUpdate) { if (hasPageUpdate) {
return await updatePage(); return await updatePage();
} }
} }