Skip to content

Commit a06c6b7

Browse files
committed
feat: support Vite 8 bundledDev mode
Use an inline import with order:'pre' in transformIndexHtml so Vite's HTML pipeline picks up the inspector module before bundling. This works in both normal dev and Vite 8 bundledDev mode without any special entry-point detection logic.
1 parent c28567b commit a06c6b7

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

packages/core/src/index.ts

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -205,12 +205,11 @@ function VitePluginInspector(options: VitePluginInspectorOptions = DEFAULT_INSPE
205205
if (isJsx || isTpl)
206206
return compileSFCTemplate({ code, id: filename, type: isJsx ? 'jsx' : 'template' })
207207

208-
if (!appendTo)
209-
return
210-
211-
if ((typeof appendTo === 'string' && filename.endsWith(appendTo))
212-
|| (appendTo instanceof RegExp && appendTo.test(filename)))
213-
return { code: `${code}\nimport 'virtual:vue-inspector-path:load.js'` }
208+
if (appendTo) {
209+
if ((typeof appendTo === 'string' && filename.endsWith(appendTo))
210+
|| (appendTo instanceof RegExp && (appendTo.lastIndex = 0, appendTo.test(filename))))
211+
return { code: `${code}\nimport 'virtual:vue-inspector-path:load.js'` }
212+
}
214213
},
215214
configureServer(server) {
216215
const _printUrls = server.printUrls
@@ -222,22 +221,23 @@ function VitePluginInspector(options: VitePluginInspectorOptions = DEFAULT_INSPE
222221
console.log(` ${green('➜')} ${bold('Vue Inspector')}: ${green(`Press ${yellow(keys)} in App to toggle the Inspector`)}\n`)
223222
})
224223
},
225-
transformIndexHtml(html) {
226-
if (appendTo)
227-
return
228-
return {
229-
html,
230-
tags: [
231-
{
232-
tag: 'script',
233-
injectTo: 'head',
234-
attrs: {
235-
type: 'module',
236-
src: `${config.base || '/'}@id/virtual:vue-inspector-path:load.js`,
224+
transformIndexHtml: {
225+
order: 'pre',
226+
handler(html) {
227+
if (appendTo)
228+
return
229+
return {
230+
html,
231+
tags: [
232+
{
233+
tag: 'script',
234+
injectTo: 'head',
235+
attrs: { type: 'module' },
236+
children: 'import \'virtual:vue-inspector-path:load.js\'',
237237
},
238-
},
239-
],
240-
}
238+
],
239+
}
240+
},
241241
},
242242
configResolved(resolvedConfig) {
243243
config = resolvedConfig

0 commit comments

Comments
 (0)