Skip to content

Commit

Permalink
feat: resolve vuetify base with given root
Browse files Browse the repository at this point in the history
  • Loading branch information
codable committed May 26, 2024
1 parent 4a40d39 commit e5a5acd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions packages/shared/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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?: string) {
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 {
Expand Down
6 changes: 4 additions & 2 deletions packages/vite-plugin/src/stylesPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, string>()
Expand All @@ -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)
}
}
},
Expand Down

0 comments on commit e5a5acd

Please sign in to comment.