File tree Expand file tree Collapse file tree 1 file changed +21
-21
lines changed
Expand file tree Collapse file tree 1 file changed +21
-21
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments