ts/vite.config.ts

72 lines
1.6 KiB
TypeScript
Raw Normal View History

2024-12-09 06:44:52 +00:00
import { fileURLToPath, URL } from 'node:url'
2025-01-06 01:18:58 +00:00
import { defineConfig, loadEnv } from 'vite'
2024-12-09 06:44:52 +00:00
import vue from '@vitejs/plugin-vue'
import WindiCSS from 'vite-plugin-windicss'
import vueJsx from '@vitejs/plugin-vue-jsx'
2024-12-09 06:44:52 +00:00
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { NaiveUiResolver } from 'unplugin-vue-components/resolvers'
// https://vitejs.dev/config/
2025-01-06 01:18:58 +00:00
export default defineConfig(({ command, mode }) => {
const env = loadEnv(mode, process.cwd())
return {
base: env.VITE_APP_BASE_URL,
plugins: [
vue({
script: {
defineModel: true,
2024-12-09 06:44:52 +00:00
},
2025-01-06 01:18:58 +00:00
}),
vueJsx(),
WindiCSS(),
AutoImport({
imports: [
'vue',
{
'naive-ui': [
'useDialog',
'useMessage',
'useNotification',
'useLoadingBar',
],
},
],
}),
Components({
resolvers: [NaiveUiResolver()],
}),
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
},
2024-12-09 06:44:52 +00:00
},
2025-01-06 01:18:58 +00:00
server: {
open: true,
host: true,
port: 9547,
2024-12-09 06:44:52 +00:00
2025-01-06 01:18:58 +00:00
proxy: {
'/api': {
2025-02-11 02:56:16 +00:00
target: 'http://192.168.10.143:18080',
2025-05-09 01:17:02 +00:00
// target: 'http://192.168.10.156:8080',
2025-01-06 01:18:58 +00:00
ws: true,
changeOrigin: true,
rewrite: path => path.replace(/^\/api/, ''),
},
2024-12-09 06:44:52 +00:00
},
},
2025-01-06 01:18:58 +00:00
css: {
preprocessorOptions: {
scss: {
2025-05-09 01:17:02 +00:00
additionalData: `@use '@/styles/variables.scss';`,
2025-01-06 01:18:58 +00:00
},
2024-12-09 06:44:52 +00:00
},
},
2025-01-06 01:18:58 +00:00
}
2024-12-09 06:44:52 +00:00
})