Skip to content

Commit

Permalink
fix(vite): resolve paths as object and from root
Browse files Browse the repository at this point in the history
  • Loading branch information
harlan-zw committed Aug 24, 2022
1 parent 3d9b6ad commit 66cdc19
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/vite/src/plugins/alias.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,14 @@ export const AliasRuntimePlugin = () => createUnplugin<AliasPluginOptions>((user
if (tsConfigFile) {
const tsconfig = await readTSConfig(tsConfigFile)
tsconfig.compilerOptions = tsconfig.compilerOptions || {}
tsconfig.compilerOptions.paths = tsconfig.compilerOptions.paths || []
const providerTsPath = relative(ctx.root, provider)
tsconfig.compilerOptions.paths = tsconfig.compilerOptions.paths || {}
const providerTsPath = `./${relative(ctx.root, provider)}`
if (tsconfig.compilerOptions.paths[AliasProvider]?.[0] !== providerTsPath) {
tsconfig.compilerOptions.paths[AliasProvider] = [providerTsPath]
updatedTSConfig = true
}

const runtimeTsPath = relative(ctx.root, `${runtime}/index`)
const runtimeTsPath = `./${relative(ctx.root, `${runtime}/index`)}`
if (tsconfig.compilerOptions.paths[AliasRuntime]?.[0] !== runtimeTsPath) {
tsconfig.compilerOptions.paths[AliasRuntime] = [runtimeTsPath]
updatedTSConfig = true
Expand Down

0 comments on commit 66cdc19

Please sign in to comment.