2024-05-05 23:10:42 +08:00
|
|
|
import path from 'node:path'
|
|
|
|
import { defineConfig } from 'vite'
|
|
|
|
import Vue from '@vitejs/plugin-vue'
|
|
|
|
import Layouts from 'vite-plugin-vue-layouts'
|
|
|
|
import Components from 'unplugin-vue-components/vite'
|
|
|
|
import AutoImport from 'unplugin-auto-import/vite'
|
|
|
|
import VueMacros from 'unplugin-vue-macros/vite'
|
|
|
|
import VueI18n from '@intlify/unplugin-vue-i18n/vite'
|
|
|
|
import VueDevTools from 'vite-plugin-vue-devtools'
|
|
|
|
import VueRouter from 'unplugin-vue-router/vite'
|
|
|
|
import { VueRouterAutoImports } from 'unplugin-vue-router'
|
2024-04-14 23:29:34 +08:00
|
|
|
import { PrimeVueResolver } from 'unplugin-vue-components/resolvers';
|
|
|
|
|
|
|
|
// https://vitejs.dev/config/
|
|
|
|
export default defineConfig(async () => ({
|
2024-05-05 23:10:42 +08:00
|
|
|
resolve: {
|
|
|
|
alias: {
|
|
|
|
"~/": `${path.resolve(__dirname, "src")}/`,
|
|
|
|
},
|
|
|
|
},
|
2024-04-14 23:29:34 +08:00
|
|
|
plugins: [
|
2024-05-05 23:10:42 +08:00
|
|
|
VueMacros({
|
|
|
|
plugins: {
|
|
|
|
vue: Vue({
|
|
|
|
include: [/\.vue$/, /\.md$/],
|
|
|
|
}),
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
|
|
|
|
// https://github.com/posva/unplugin-vue-router
|
|
|
|
VueRouter({
|
|
|
|
extensions: ['.vue', '.md'],
|
|
|
|
dts: 'src/typed-router.d.ts',
|
|
|
|
}),
|
|
|
|
|
|
|
|
// https://github.com/JohnCampionJr/vite-plugin-vue-layouts
|
|
|
|
Layouts(),
|
|
|
|
|
|
|
|
// https://github.com/antfu/unplugin-auto-import
|
|
|
|
AutoImport({
|
|
|
|
imports: [
|
|
|
|
'vue',
|
|
|
|
'vue-i18n',
|
|
|
|
'pinia',
|
|
|
|
VueRouterAutoImports,
|
|
|
|
{
|
|
|
|
// add any other imports you were relying on
|
|
|
|
'vue-router/auto': ['useLink'],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
dts: 'src/auto-imports.d.ts',
|
|
|
|
dirs: [
|
|
|
|
'src/composables',
|
|
|
|
'src/stores',
|
|
|
|
],
|
|
|
|
vueTemplate: true,
|
|
|
|
}),
|
|
|
|
|
|
|
|
// https://github.com/antfu/unplugin-vue-components
|
2024-04-14 23:29:34 +08:00
|
|
|
Components({
|
2024-05-05 23:10:42 +08:00
|
|
|
// allow auto load markdown components under `./src/components/`
|
|
|
|
extensions: ['vue', 'md'],
|
|
|
|
// allow auto import and register components used in markdown
|
|
|
|
include: [/\.vue$/, /\.vue\?vue/, /\.md$/],
|
|
|
|
dts: 'src/components.d.ts',
|
2024-04-14 23:29:34 +08:00
|
|
|
resolvers: [
|
|
|
|
PrimeVueResolver()
|
|
|
|
]
|
2024-05-05 23:10:42 +08:00
|
|
|
}),
|
|
|
|
|
|
|
|
// https://github.com/intlify/bundle-tools/tree/main/packages/unplugin-vue-i18n
|
|
|
|
VueI18n({
|
|
|
|
runtimeOnly: true,
|
|
|
|
compositionOnly: true,
|
|
|
|
fullInstall: true,
|
|
|
|
include: [path.resolve(__dirname, 'locales/**')],
|
|
|
|
}),
|
|
|
|
|
|
|
|
// https://github.com/webfansplz/vite-plugin-vue-devtools
|
|
|
|
VueDevTools(),
|
|
|
|
],
|
2024-04-14 23:29:34 +08:00
|
|
|
|
|
|
|
// Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
|
|
|
|
//
|
|
|
|
// 1. prevent vite from obscuring rust errors
|
|
|
|
clearScreen: false,
|
|
|
|
// 2. tauri expects a fixed port, fail if that port is not available
|
|
|
|
server: {
|
|
|
|
port: 1420,
|
|
|
|
strictPort: true,
|
|
|
|
watch: {
|
|
|
|
// 3. tell vite to ignore watching `src-tauri`
|
|
|
|
ignored: ["**/src-tauri/**"],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}));
|