@@ -3,7 +3,7 @@ import { fileURLToPath } from 'node:url'
3
3
import fs from 'node:fs'
4
4
import { bold , dim , green , yellow } from 'kolorist'
5
5
import { normalizePath } from 'vite'
6
- import type { PluginOption , ServerOptions } from 'vite'
6
+ import type { PluginOption , ResolvedConfig , ServerOptions } from 'vite'
7
7
import MagicString from 'magic-string'
8
8
import { compileSFCTemplate } from './compiler'
9
9
import { idToFile , parseVueRequest } from './utils'
@@ -29,59 +29,59 @@ export interface VueInspectorClient {
29
29
30
30
export interface VitePluginInspectorOptions {
31
31
/**
32
- * Vue version
33
- * @default 3
34
- */
32
+ * Vue version
33
+ * @default 3
34
+ */
35
35
vue ?: 2 | 3
36
36
37
37
/**
38
- * Default enable state
39
- * @default false
40
- */
38
+ * Default enable state
39
+ * @default false
40
+ */
41
41
enabled ?: boolean
42
42
43
43
/**
44
- * Define a combo key to toggle inspector
45
- * @default 'control-shift' on windows, 'meta-shift' on other os
46
- *
47
- * any number of modifiers `control` `shift` `alt` `meta` followed by zero or one regular key, separated by -
48
- * examples: control-shift, control-o, control-alt-s meta-x control-meta
49
- * Some keys have native behavior (e.g. alt-s opens history menu on firefox).
50
- * To avoid conflicts or accidentally typing into inputs, modifier only combinations are recommended.
51
- * You can also disable it by setting `false`.
52
- */
44
+ * Define a combo key to toggle inspector
45
+ * @default 'control-shift' on windows, 'meta-shift' on other os
46
+ *
47
+ * any number of modifiers `control` `shift` `alt` `meta` followed by zero or one regular key, separated by -
48
+ * examples: control-shift, control-o, control-alt-s meta-x control-meta
49
+ * Some keys have native behavior (e.g. alt-s opens history menu on firefox).
50
+ * To avoid conflicts or accidentally typing into inputs, modifier only combinations are recommended.
51
+ * You can also disable it by setting `false`.
52
+ */
53
53
toggleComboKey ?: string | false
54
54
55
55
/**
56
- * Toggle button visibility
57
- * @default 'active'
58
- */
56
+ * Toggle button visibility
57
+ * @default 'active'
58
+ */
59
59
toggleButtonVisibility ?: 'always' | 'active' | 'never'
60
60
61
61
/**
62
- * Toggle button display position
63
- * @default top-right
64
- */
62
+ * Toggle button display position
63
+ * @default top-right
64
+ */
65
65
toggleButtonPos ?: 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left'
66
66
67
67
/**
68
- * append an import to the module id ending with `appendTo` instead of adding a script into body
69
- * useful for frameworks that do not support transformIndexHtml hook (e.g. Nuxt3)
70
- *
71
- * WARNING: only set this if you know exactly what it does.
72
- */
68
+ * append an import to the module id ending with `appendTo` instead of adding a script into body
69
+ * useful for frameworks that do not support transformIndexHtml hook (e.g. Nuxt3)
70
+ *
71
+ * WARNING: only set this if you know exactly what it does.
72
+ */
73
73
appendTo ?: string | RegExp
74
74
75
75
/**
76
- * Customize openInEditor host (e.g. http://localhost:3000)
77
- * @default false
78
- */
76
+ * Customize openInEditor host (e.g. http://localhost:3000)
77
+ * @default false
78
+ */
79
79
openInEditorHost ?: string | false
80
80
81
81
/**
82
82
* lazy load inspector times (ms)
83
83
* @default false
84
- */
84
+ */
85
85
lazyLoad ?: number | false
86
86
87
87
/**
@@ -133,6 +133,7 @@ function VitePluginInspector(options: VitePluginInspectorOptions = DEFAULT_INSPE
133
133
...options ,
134
134
}
135
135
let serverOptions : ServerOptions | undefined
136
+ let config : ResolvedConfig
136
137
137
138
const {
138
139
vue,
@@ -187,7 +188,7 @@ function VitePluginInspector(options: VitePluginInspectorOptions = DEFAULT_INSPE
187
188
return
188
189
189
190
if ( ( typeof appendTo === 'string' && filename . endsWith ( appendTo ) )
190
- || ( appendTo instanceof RegExp && appendTo . test ( filename ) ) )
191
+ || ( appendTo instanceof RegExp && appendTo . test ( filename ) ) )
191
192
return { code : `${ code } \nimport 'virtual:vue-inspector-path:load.js'` }
192
193
} ,
193
194
configureServer ( server ) {
@@ -211,13 +212,14 @@ function VitePluginInspector(options: VitePluginInspectorOptions = DEFAULT_INSPE
211
212
injectTo : 'head' ,
212
213
attrs : {
213
214
type : 'module' ,
214
- src : '/ @id/virtual:vue-inspector-path:load.js' ,
215
+ src : ` ${ config . base || '/' } @id/virtual:vue-inspector-path:load.js` ,
215
216
} ,
216
217
} ,
217
218
] ,
218
219
}
219
220
} ,
220
221
configResolved ( resolvedConfig ) {
222
+ config = resolvedConfig
221
223
serverOptions = resolvedConfig . server
222
224
} ,
223
225
} ,
0 commit comments