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