Skip to content

How to integrate paths of tsconfig with vitepress? #2746

Closed Locked Answered by brc-dd
zhangzhuang15 asked this question in Q&A
Discussion options

You must be logged in to vote

Is there a black magic behind @theme or .vitepress/theme ?

Yes. @theme imports have different meaning. For @components/ you need to configure vite aliases along with tsconfig too:

something like this should work:

// .vitepress/config.ts
import { fileURLToPath } from 'node:url'
import { defineConfig } from 'vitepress'

export default defineConfig({
 vite: {
    resolve: {
      alias: {
        '@components': fileURLToPath(new URL('./theme/components', import.meta.url))
      }
    }
  }
})

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@zhangzhuang15
Comment options

Answer selected by zhangzhuang15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants