diff --git a/packages/shared/src/index.ts b/packages/shared/src/index.ts index bca2c59..312e1e5 100644 --- a/packages/shared/src/index.ts +++ b/packages/shared/src/index.ts @@ -22,8 +22,10 @@ export type ImportPluginOptions = export { generateImports } from './imports/generateImports' -export function resolveVuetifyBase () { - return path.dirname(require.resolve('vuetify/package.json', { paths: [process.cwd()] })) +export function resolveVuetifyBase (root) { + const paths = (root && root != process.cwd()) ? [root] : []; + paths.push(process.cwd()); + return path.dirname(require.resolve('vuetify/package.json', { paths })) } export function isObject (value: any): value is object { diff --git a/packages/vite-plugin/src/stylesPlugin.ts b/packages/vite-plugin/src/stylesPlugin.ts index ba89fd5..1bd8245 100644 --- a/packages/vite-plugin/src/stylesPlugin.ts +++ b/packages/vite-plugin/src/stylesPlugin.ts @@ -10,7 +10,7 @@ function isSubdir (root: string, test: string) { } export function stylesPlugin (options: Options): Plugin { - const vuetifyBase = resolveVuetifyBase() + let vuetifyBase: string let configFile: string const tempFiles = new Map() @@ -19,11 +19,13 @@ export function stylesPlugin (options: Options): Plugin { name: 'vuetify:styles', enforce: 'pre', configResolved (config) { + const root = config.root || process.cwd(); + vuetifyBase = resolveVuetifyBase(root) if (isObject(options.styles)) { if (path.isAbsolute(options.styles.configFile)) { configFile = options.styles.configFile } else { - configFile = path.join(config.root || process.cwd(), options.styles.configFile) + configFile = path.join(root, options.styles.configFile) } } },