From 4e6898f5bc8937be5cf8f1ff7427db9e3e6d2732 Mon Sep 17 00:00:00 2001 From: Robin Bomkamp <49171265+RobinBomkamp@users.noreply.github.com> Date: Mon, 2 Dec 2024 23:27:19 +0100 Subject: [PATCH] fix: SvelteKit dev build is not working (#206) * fix: Do not inject code into html files while ssr builds * fix: Correct htmlFilePath detection * fix: Dev mode is not working in SvelteKit --------- Co-authored-by: Robin Bomkamp --- src/plugins/pluginAddEntry.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/plugins/pluginAddEntry.ts b/src/plugins/pluginAddEntry.ts index e257cfd..83eee64 100644 --- a/src/plugins/pluginAddEntry.ts +++ b/src/plugins/pluginAddEntry.ts @@ -75,6 +75,19 @@ const addEntry = ({ )}>` ); }, + transform(code, id) { + if (id.includes('node_modules') || inject !== 'html' || htmlFilePath) { + return; + } + + if (id.includes('.svelte-kit') && id.includes('internal.js')) { + const src = devEntryPath.replace(/.+?\:([/\\])[/\\]?/, '$1').replace(/\\\\?/g, '/'); + return code.replace( + //g, + '' + ); + } + }, }, { name: 'add-entry',