2025-04-24 20:39:31 +08:00
|
|
|
import {fileURLToPath, URL} from 'node:url'
|
2025-04-18 17:17:23 +08:00
|
|
|
|
2025-04-24 20:39:31 +08:00
|
|
|
import {defineConfig} from 'vite'
|
2025-04-18 17:17:23 +08:00
|
|
|
import vue from '@vitejs/plugin-vue'
|
2025-04-22 15:46:48 +08:00
|
|
|
import Icons from 'unplugin-icons/vite'
|
|
|
|
import IconsResolver from 'unplugin-icons/resolver'
|
2025-04-18 17:17:23 +08:00
|
|
|
import vueDevTools from 'vite-plugin-vue-devtools'
|
|
|
|
|
|
|
|
import AutoImport from 'unplugin-auto-import/vite'
|
|
|
|
import Components from 'unplugin-vue-components/vite'
|
2025-04-24 20:39:31 +08:00
|
|
|
import {ElementPlusResolver} from 'unplugin-vue-components/resolvers'
|
|
|
|
import {loadEnv} from 'vite'
|
2025-04-18 17:17:23 +08:00
|
|
|
|
|
|
|
// https://vite.dev/config/
|
2025-04-24 20:39:31 +08:00
|
|
|
export default defineConfig(({mode, command}) => {
|
|
|
|
const env = loadEnv(mode, process.cwd())
|
|
|
|
const {VITE_APP_ENV, VITE_APP_BASE_URL, VITE_APP_BASE_URL_WS} = env
|
|
|
|
return {
|
|
|
|
plugins: [
|
|
|
|
vue(),
|
|
|
|
vueDevTools(),
|
|
|
|
AutoImport({
|
|
|
|
imports: ['vue'],
|
|
|
|
resolvers: [
|
|
|
|
ElementPlusResolver(),
|
|
|
|
IconsResolver({
|
|
|
|
prefix: 'Icon',
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
}),
|
|
|
|
Components({
|
|
|
|
resolvers: [
|
|
|
|
IconsResolver({
|
|
|
|
enabledCollections: ['ep'],
|
|
|
|
}),
|
|
|
|
ElementPlusResolver(),
|
|
|
|
],
|
|
|
|
}),
|
2025-04-22 15:46:48 +08:00
|
|
|
|
2025-04-24 20:39:31 +08:00
|
|
|
Icons({
|
|
|
|
autoInstall: true,
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
|
|
|
'@': fileURLToPath(new URL('./src', import.meta.url))
|
|
|
|
},
|
|
|
|
},
|
2025-04-18 17:17:23 +08:00
|
|
|
|
2025-04-24 20:39:31 +08:00
|
|
|
// vite 相关配置
|
|
|
|
server: {
|
|
|
|
port: 5174,
|
|
|
|
host: true,
|
|
|
|
open: false,
|
2025-04-18 17:17:23 +08:00
|
|
|
|
|
|
|
|
2025-04-24 20:39:31 +08:00
|
|
|
proxy: {
|
|
|
|
// https://cn.vitejs.dev/config/#server-proxy
|
|
|
|
'/api': {
|
|
|
|
target: VITE_APP_BASE_URL,
|
|
|
|
changeOrigin: true,
|
|
|
|
rewrite: (p) => p.replace(/^\/api/, ''),
|
|
|
|
},
|
2025-04-18 17:17:23 +08:00
|
|
|
|
2025-04-24 20:39:31 +08:00
|
|
|
// '/dev-ws': {
|
|
|
|
// target: VITE_APP_BASE_URL_WS,
|
|
|
|
// changeOrigin: true,
|
|
|
|
// rewrite: (p) => p.replace(/^\/dev-ws/, ''),
|
|
|
|
// ws: true
|
|
|
|
// }
|
2025-04-18 17:17:23 +08:00
|
|
|
|
2025-04-24 20:39:31 +08:00
|
|
|
}
|
|
|
|
},
|
2025-04-27 17:23:19 +08:00
|
|
|
|
|
|
|
css: {
|
|
|
|
//fix Deprecation Warning: The legacy JS API is deprecated and will be removed in Dart Sass 2.0.0.
|
|
|
|
preprocessorOptions: {
|
|
|
|
scss: {
|
|
|
|
api: 'modern-compiler',
|
|
|
|
}
|
|
|
|
},
|
|
|
|
postcss: {
|
|
|
|
plugins: [
|
|
|
|
{
|
|
|
|
postcssPlugin: 'internal:charset-removal',
|
|
|
|
AtRule: {
|
|
|
|
charset: (atRule) => {
|
|
|
|
if (atRule.name === 'charset') {
|
|
|
|
atRule.remove();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
,
|
2025-04-24 20:39:31 +08:00
|
|
|
}
|
2025-04-18 17:17:23 +08:00
|
|
|
})
|