Skip to content

Commit 9790719

Browse files
committed
refactor: create VIRTUAL_MODULE_ID constant for unify values
1 parent 38b0dc1 commit 9790719

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

packages/vite-plugin/src/stylesPlugin.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ function isSubdir (root: string, test: string) {
1111

1212
const PLUGIN_VIRTUAL_PREFIX = "virtual:"
1313
const PLUGIN_VIRTUAL_NAME = "plugin-vuetify"
14+
const VIRTUAL_MODULE_ID = `${PLUGIN_VIRTUAL_PREFIX}${PLUGIN_VIRTUAL_NAME}`
1415

1516
export function stylesPlugin (options: Options): Plugin {
1617
const vuetifyBase = resolveVuetifyBase()
@@ -54,7 +55,7 @@ export function stylesPlugin (options: Options): Plugin {
5455

5556
tempFiles.set(file, contents)
5657

57-
return `${PLUGIN_VIRTUAL_PREFIX}${PLUGIN_VIRTUAL_NAME}:${file}`
58+
return `${VIRTUAL_MODULE_ID}:${file}`
5859
}
5960
} else if (source.startsWith(`/${PLUGIN_VIRTUAL_NAME}:`)) {
6061
return PLUGIN_VIRTUAL_PREFIX + source.slice(1)
@@ -71,8 +72,8 @@ export function stylesPlugin (options: Options): Plugin {
7172
return ''
7273
}
7374

74-
if (id.startsWith(`${PLUGIN_VIRTUAL_PREFIX}${PLUGIN_VIRTUAL_NAME}`)) {
75-
const file = new RegExp(`^${PLUGIN_VIRTUAL_PREFIX}${PLUGIN_VIRTUAL_NAME}:(.*?)(\\?.*)?$`).exec(id)![1]
75+
if (id.startsWith(`${VIRTUAL_MODULE_ID}`)) {
76+
const file = new RegExp(`^${VIRTUAL_MODULE_ID}:(.*?)(\\?.*)?$`).exec(id)![1]
7677

7778
return tempFiles.get(file)
7879
}

0 commit comments

Comments
 (0)