Skip to content

Commit f1da0ba

Browse files
committed
fix(vite): improve path resolving
1 parent 72c1428 commit f1da0ba

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

packages/vite/src/plugins.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export interface PluginOptions {
1919
pkgDir?: string
2020
provider?: string
2121
runtime?: string
22+
mockPath?: string
2223
}
2324
/**
2425
* Scan files from this root directory (ignoring node_modules).
@@ -29,6 +30,7 @@ export interface PluginOptions {
2930
const SchemaOrgPkg = '@vueuse/schema-org'
3031

3132
interface AliasPaths {
33+
mockPath?: string
3234
pkgDir: string
3335
provider: string
3436
runtime: string
@@ -43,11 +45,12 @@ export const schemaOrgSwapAliases = () => createUnplugin<PluginOptions>((args) =
4345
const pkgDir = args.aliasPaths?.pkgDir || dirname(await resolvePath(SchemaOrgPkg))
4446
let provider, runtime
4547
if (args?.mock) {
46-
provider = runtime = await resolvePath(`${SchemaOrgPkg}/runtime/mock`)
48+
const mockPath = args.aliasPaths?.mockPath || await resolvePath(`${pkgDir}/runtime-mock`)
49+
provider = runtime = mockPath
4750
}
4851
else {
49-
provider = args.aliasPaths?.provider || await resolvePath(`${SchemaOrgPkg}/${args?.full ? 'full' : 'simple'}`)
50-
runtime = args.aliasPaths?.runtime || await resolvePath(`${SchemaOrgPkg}/runtime`)
52+
provider = args.aliasPaths?.provider || await resolvePath(`${pkgDir}/providers/${args?.full ? 'full' : 'simple'}`)
53+
runtime = args.aliasPaths?.runtime || await resolvePath(`${pkgDir}/runtime`)
5154
}
5255
paths = {
5356
pkgDir,

0 commit comments

Comments
 (0)