mirror of
https://github.com/EasyTier/EasyTier.git
synced 2024-11-16 03:32:43 +08:00
110 lines
2.9 KiB
TypeScript
110 lines
2.9 KiB
TypeScript
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'
|
|
import { PrimeVueResolver } from '@primevue/auto-import-resolver';
|
|
import { svelte } from '@sveltejs/vite-plugin-svelte';
|
|
import { internalIpV4Sync } from 'internal-ip';
|
|
|
|
const host = process.env.TAURI_DEV_HOST;
|
|
|
|
// https://vitejs.dev/config/
|
|
export default defineConfig(async () => ({
|
|
resolve: {
|
|
alias: {
|
|
'~/': `${path.resolve(__dirname, 'src')}/`,
|
|
},
|
|
},
|
|
plugins: [
|
|
svelte(),
|
|
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
|
|
Components({
|
|
// 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',
|
|
resolvers: [
|
|
PrimeVueResolver(),
|
|
],
|
|
}),
|
|
|
|
// 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(),
|
|
],
|
|
|
|
// 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,
|
|
host: host || false,
|
|
strictPort: true,
|
|
watch: {
|
|
// 3. tell vite to ignore watching `src-tauri`
|
|
ignored: ['**/src-tauri/**'],
|
|
},
|
|
hmr: host
|
|
? {
|
|
protocol: 'ws',
|
|
host: internalIpV4Sync(),
|
|
port: 1430,
|
|
}
|
|
: undefined,
|
|
},
|
|
}))
|