|
1 | 1 | import process from 'node:process'
|
2 | 2 | import { pathToFileURL } from 'node:url'
|
3 |
| -import { existsSync } from 'node:fs' |
| 3 | +import fs from 'node:fs' |
| 4 | +import fsp from 'node:fs/promises' |
4 | 5 | import type { Plugin } from 'vite'
|
5 | 6 | import { isObject, normalizePath, resolveVuetifyBase } from '@vuetify/loader-shared'
|
6 | 7 | import { isAbsolute, relative as relativePath } from 'pathe'
|
@@ -66,13 +67,13 @@ export function vuetifyStylesPlugin(
|
66 | 67 | )
|
67 | 68 | ) {
|
68 | 69 | if (options.styles === 'sass')
|
69 |
| - return this.resolve(resolveCss(source), importer, { skipSelf: true, custom }) |
| 70 | + return this.resolve(await resolveCss(source), importer, { skipSelf: true, custom }) |
70 | 71 |
|
71 | 72 | const resolution = await this.resolve(source, importer, { skipSelf: true, custom })
|
72 | 73 | if (!resolution)
|
73 | 74 | return undefined
|
74 | 75 |
|
75 |
| - const target = resolveCss(resolution.id) |
| 76 | + const target = await resolveCss(resolution.id) |
76 | 77 | if (isNone) {
|
77 | 78 | noneFiles.add(target)
|
78 | 79 | return target
|
@@ -108,15 +109,16 @@ export function vuetifyStylesPlugin(
|
108 | 109 |
|
109 | 110 | function resolveCssFactory() {
|
110 | 111 | const mappings = new Map<string, string>()
|
111 |
| - return (source: string) => { |
| 112 | + return async (source: string) => { |
112 | 113 | let mapping = mappings.get(source)
|
113 | 114 | if (!mapping) {
|
114 | 115 | try {
|
115 | 116 | mapping = source.replace(/\.css$/, '.sass')
|
116 |
| - if (!existsSync(mapping)) |
117 |
| - mapping = source.replace(/\.css$/, '.scss') |
| 117 | + await fsp.access(mapping, fs.constants.R_OK) |
118 | 118 | }
|
119 |
| - catch { |
| 119 | + catch (err) { |
| 120 | + if (!(err instanceof Error && 'code' in err && err.code === 'ENOENT')) |
| 121 | + throw err |
120 | 122 | mapping = source.replace(/\.css$/, '.scss')
|
121 | 123 | }
|
122 | 124 | mappings.set(source, mapping)
|
|
0 commit comments