Skip to content

Commit 612f568

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. Also reset appendTo regex lastIndex before test() to prevent skipped matches when a global-flag regex is used.
1 parent c28567b commit 612f568

1 file changed

Lines changed: 17 additions & 16 deletions

File tree

packages/core/src/index.ts

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ function VitePluginInspector(options: VitePluginInspectorOptions = DEFAULT_INSPE
209209
return
210210

211211
if ((typeof appendTo === 'string' && filename.endsWith(appendTo))
212-
|| (appendTo instanceof RegExp && appendTo.test(filename)))
212+
|| (appendTo instanceof RegExp && (appendTo.lastIndex = 0, appendTo.test(filename))))
213213
return { code: `${code}\nimport 'virtual:vue-inspector-path:load.js'` }
214214
},
215215
configureServer(server) {
@@ -222,22 +222,23 @@ function VitePluginInspector(options: VitePluginInspectorOptions = DEFAULT_INSPE
222222
console.log(` ${green('➜')} ${bold('Vue Inspector')}: ${green(`Press ${yellow(keys)} in App to toggle the Inspector`)}\n`)
223223
})
224224
},
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`,
225+
transformIndexHtml: {
226+
order: 'pre',
227+
handler(html) {
228+
if (appendTo)
229+
return
230+
return {
231+
html,
232+
tags: [
233+
{
234+
tag: 'script',
235+
injectTo: 'head',
236+
attrs: { type: 'module' },
237+
children: 'import \'virtual:vue-inspector-path:load.js\'',
237238
},
238-
},
239-
],
240-
}
239+
],
240+
}
241+
},
241242
},
242243
configResolved(resolvedConfig) {
243244
config = resolvedConfig

0 commit comments

Comments
 (0)