Skip to content

Commit

Permalink
fix: always try relative path for mapped hooks (QwikDev#4686)
Browse files Browse the repository at this point in the history
  • Loading branch information
manucorporat authored Jul 2, 2023
1 parent 9be4247 commit 0f908f3
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion packages/qwik/src/optimizer/src/plugins/vite-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export async function configureDevServer(
url += `?t=${v.lastHMRTimestamp}`;
}
if (hook) {
manifest.mapping[hook.name] = url;
manifest.mapping[hook.name] = relativeURL(url, opts.rootDir);
}

const { pathId, query } = parseId(v.url);
Expand All @@ -126,6 +126,7 @@ export async function configureDevServer(
const srcBase = opts.srcDir
? path.relative(opts.rootDir, opts.srcDir).replace(/\\/g, '/')
: 'src';

const renderOpts: RenderToStreamOptions = {
debug: true,
locale: serverData.locale,
Expand Down Expand Up @@ -320,6 +321,16 @@ declare global {
}
}

function relativeURL(url: string, base: string) {
if (url.startsWith(base)) {
url = url.slice(base.length);
if (!url.startsWith('/')) {
url = '/' + url;
}
}
return url;
}

const DEV_QWIK_INSPECTOR = (opts: NormalizedQwikPluginOptions['devTools'], srcDir: string) => {
const qwikdevtools = {
hotKeys: opts.clickToSource ?? [],
Expand Down

0 comments on commit 0f908f3

Please sign in to comment.