@@ -9,6 +9,10 @@ function isSubdir (root: string, test: string) {
9
9
return relative && ! relative . startsWith ( '..' ) && ! path . isAbsolute ( relative )
10
10
}
11
11
12
+ const PLUGIN_VIRTUAL_PREFIX = "virtual:"
13
+ const PLUGIN_VIRTUAL_NAME = "plugin-vuetify"
14
+ const VIRTUAL_MODULE_ID = `${ PLUGIN_VIRTUAL_PREFIX } ${ PLUGIN_VIRTUAL_NAME } `
15
+
12
16
export function stylesPlugin ( options : Options ) : Plugin {
13
17
const vuetifyBase = resolveVuetifyBase ( )
14
18
@@ -36,7 +40,7 @@ export function stylesPlugin (options: Options): Plugin {
36
40
)
37
41
) {
38
42
if ( options . styles === 'none' ) {
39
- return '\0__void__'
43
+ return ` ${ PLUGIN_VIRTUAL_PREFIX } __void__`
40
44
} else if ( options . styles === 'sass' ) {
41
45
const target = source . replace ( / \. c s s $ / , '.sass' )
42
46
return this . resolve ( target , importer , { skipSelf : true , custom } )
@@ -51,25 +55,27 @@ export function stylesPlugin (options: Options): Plugin {
51
55
52
56
tempFiles . set ( file , contents )
53
57
54
- return `\0plugin-vuetify :${ file } `
58
+ return `${ VIRTUAL_MODULE_ID } :${ file } `
55
59
}
56
- } else if ( source . startsWith ( '/plugin-vuetify:' ) ) {
57
- return '\0' + source . slice ( 1 )
58
- } else if ( source . startsWith ( '/@id/__x00__plugin-vuetify:' ) ) {
59
- return '\0' + source . slice ( 12 )
60
+ } else if ( source . startsWith ( `/${ PLUGIN_VIRTUAL_NAME } :` ) ) {
61
+ return PLUGIN_VIRTUAL_PREFIX + source . slice ( 1 )
62
+ } else if ( source . startsWith ( `/@id/__x00__${ PLUGIN_VIRTUAL_NAME } :` ) ) {
63
+ return PLUGIN_VIRTUAL_PREFIX + source . slice ( 12 )
64
+ } else if ( source . startsWith ( `/${ VIRTUAL_MODULE_ID } :` ) ) {
65
+ return source . slice ( 1 )
60
66
}
61
67
62
68
return null
63
69
} ,
64
70
load ( id ) {
65
71
// When Vite is configured with `optimizeDeps.exclude: ['vuetify']`, the
66
72
// received id contains a version hash (e.g. \0__void__?v=893fa859).
67
- if ( / ^ \0 _ _ v o i d _ _ ( \ ? .* ) ? $ / . test ( id ) ) {
73
+ if ( new RegExp ( `^ ${ PLUGIN_VIRTUAL_PREFIX } __void__(\\ ?.*)?$` ) . test ( id ) ) {
68
74
return ''
69
75
}
70
76
71
- if ( id . startsWith ( '\0plugin-vuetify' ) ) {
72
- const file = / ^ \0 p l u g i n - v u e t i f y : ( .* ?) ( \? .* ) ? $ / . exec ( id ) ! [ 1 ]
77
+ if ( id . startsWith ( ` ${ VIRTUAL_MODULE_ID } ` ) ) {
78
+ const file = new RegExp ( `^ ${ VIRTUAL_MODULE_ID } :(.*?)(\\ ?.*)?$` ) . exec ( id ) ! [ 1 ]
73
79
74
80
return tempFiles . get ( file )
75
81
}
0 commit comments