Closed IlyaSemenov closed 3 years ago
Use vite-tsconfig-paths@2
instead
@aleclarson its doesn't seem to work.
npm init @vitejs/app <project-name>
compilerOptions
:
"baseUrl": ".",
"paths": {
"@/*": ["src/*"]
}
vite.config.ts
:
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import tsconfigPaths from 'vite-tsconfig-paths'
export default defineConfig({ plugins: [vue(), tsconfigPaths()] })
- Update App.vue to import HelloWorld.vue with `@/`:
```ts
import HelloWorld from '@/components/HelloWorld.vue'
My full package.json, for reference:
{
"name": "my-project",
"version": "0.0.0",
"scripts": {
"dev": "vite",
"build": "vuedx-typecheck . && vite build"
},
"dependencies": {
"vue": "^3.0.5"
},
"devDependencies": {
"@vitejs/plugin-vue": "^1.0.4",
"@vue/compiler-sfc": "^3.0.5",
"@vuedx/typecheck": "^0.4.1",
"@vuedx/typescript-plugin-vue": "^0.4.1",
"typescript": "^4.1.3",
"vite": "^2.0.0-beta.12",
"vite-tsconfig-paths": "^2.0.0"
}
}
Edit: the solution from https://github.com/vitejs/vite/issues/88#issuecomment-762415200 works, but I'd rather your use your plugin to avoid keeping both files in sync when I'll add more aliases :)
@scambier See #4. The path mapping should only apply to lang="ts"
scripts in .vue
modules, but it's not implemented yet.
The plugin doesn't work with Vite 2:
It also seems that
resolvers
is not more a valid property atvite.UserConfig
.