53 lines
1.4 KiB
TypeScript
53 lines
1.4 KiB
TypeScript
|
|
import { fileURLToPath, URL } from 'node:url'
|
||
|
|
|
||
|
|
import { defineConfig } from 'vite'
|
||
|
|
import vue from '@vitejs/plugin-vue'
|
||
|
|
import vueJsx from '@vitejs/plugin-vue-jsx'
|
||
|
|
import vueDevTools from 'vite-plugin-vue-devtools'
|
||
|
|
import AutoImport from 'unplugin-auto-import/vite'
|
||
|
|
import Components from 'unplugin-vue-components/vite'
|
||
|
|
|
||
|
|
// https://vite.dev/config/
|
||
|
|
export default defineConfig({
|
||
|
|
plugins: [
|
||
|
|
vue(),
|
||
|
|
vueJsx(),
|
||
|
|
vueDevTools(),
|
||
|
|
AutoImport({
|
||
|
|
// 自动导入Vue相关API
|
||
|
|
imports: [
|
||
|
|
'vue',
|
||
|
|
'vue-router',
|
||
|
|
'pinia',
|
||
|
|
// 可以添加更多需要自动导入的库
|
||
|
|
],
|
||
|
|
// 生成自动导入的TS声明文件
|
||
|
|
dts: 'src/auto-imports.d.ts',
|
||
|
|
// 自动导入目录下的模块
|
||
|
|
dirs: [
|
||
|
|
'src/composables',
|
||
|
|
'src/stores',
|
||
|
|
],
|
||
|
|
// 自动导入的API前缀
|
||
|
|
vueTemplate: true,
|
||
|
|
}),
|
||
|
|
Components({
|
||
|
|
// 指定组件所在目录,默认为 src/components
|
||
|
|
dirs: ['src/components'],
|
||
|
|
// 组件的有效文件扩展名
|
||
|
|
extensions: ['vue', 'tsx'],
|
||
|
|
// 配置文件生成位置
|
||
|
|
dts: 'src/components.d.ts',
|
||
|
|
// 搜索子目录
|
||
|
|
deep: true,
|
||
|
|
// 允许子目录作为组件的命名空间前缀
|
||
|
|
directoryAsNamespace: false,
|
||
|
|
}),
|
||
|
|
],
|
||
|
|
resolve: {
|
||
|
|
alias: {
|
||
|
|
'@': fileURLToPath(new URL('./src', import.meta.url))
|
||
|
|
},
|
||
|
|
},
|
||
|
|
})
|