Skip to content

Commit 689ffc9

Browse files
committed
fix(dev): click to component with base
1 parent aaaaf82 commit 689ffc9

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

packages/qwik/src/optimizer/src/plugins/dev/click-to-component.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ if (typeof document !== 'undefined') {
22
const register = () => {
33
const inspectAttribute = 'data-qwik-inspector';
44
const hotKeys = globalThis.__HOTKEYS__;
5-
const srcDir = globalThis.__SRC_DIR__;
5+
const base = globalThis.__BASE__;
66
let popup = document.querySelector('#qwik-inspector-info-popup');
77
if (!popup) {
88
popup = document.createElement('div');
@@ -92,7 +92,7 @@ if (typeof document !== 'undefined') {
9292
const match = inspectUrl.match(/^(.*?)(:\d+(:\d+)?)?$/);
9393
if (match) {
9494
const [, filePath, location] = match;
95-
fetch(`${filePath}?editor${location}`).then(() => {
95+
fetch(`${base}${filePath}?editor${location}`).then(() => {
9696
body.style.removeProperty('cursor');
9797
});
9898
}

packages/qwik/src/optimizer/src/plugins/dev/index.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ function invalidPreviewMessage(middlewares: Connect.Server, msg: string) {
7777
});
7878
}
7979

80-
export const getViteIndexTags = (opts: NormalizedQwikPluginOptions, srcDir: string) => {
80+
export const getViteIndexTags = (opts: NormalizedQwikPluginOptions, base: string) => {
8181
const tags: HtmlTagDescriptor[] = [
8282
{ tag: 'style', children: qwikErrorOverlayStyles, injectTo: 'body' },
8383
{ tag: 'style', children: inspectorStyles, injectTo: 'body' },
@@ -104,13 +104,16 @@ export const getViteIndexTags = (opts: NormalizedQwikPluginOptions, srcDir: stri
104104
}
105105
if (opts.devTools?.clickToSource ?? true) {
106106
const hotKeys = opts.devTools.clickToSource ?? [];
107-
const srcDirUrl = new URL(srcDir + '/', 'http://local.local').href;
107+
// the filepaths start with /
108+
if (base.endsWith('/')) {
109+
base = base.slice(0, -1);
110+
}
108111
tags.push({
109112
tag: 'script',
110113
attrs: { type: 'module' },
111114
children: clickToComponent
112115
.replace('globalThis.__HOTKEYS__', JSON.stringify(hotKeys))
113-
.replace('globalThis.__SRC_DIR__', JSON.stringify(srcDirUrl)),
116+
.replace('globalThis.__BASE__', JSON.stringify(base)),
114117
injectTo: 'body',
115118
});
116119
}

0 commit comments

Comments
 (0)