version: 2

This commit is contained in:
2026-11-05 10:46:36 +08:00
parent 1a9220364b
commit 98ff2d0a35
53 changed files with 8177 additions and 2010 deletions
+31 -2
View File
@@ -3,6 +3,7 @@ import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import pkg from "./package.json" with { type: "json" };
// 注意:页面跑在 5173,one-api 在 127.0.0.1:3100(SSH 隧道)—— 两者跨源。
// 必须靠这个 proxy 把 /v1 转过去,让页面请求**同源相对路径**,否则带
@@ -16,8 +17,9 @@ export default defineConfig({
dts: false, // 不生成 components.d.ts,项目里 EP 组件都是显式 import 的
}),
],
// 必须与 tsconfig.json 的 paths 保持一致,否则 @/ 开头的 import
// 能过类型检查但在 dev/build 时解析失败。
define: {
__APP_VERSION__: JSON.stringify(pkg.version),
},
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
@@ -33,4 +35,31 @@ export default defineConfig({
},
},
},
build: {
chunkSizeWarningLimit: 2000,
rolldownOptions: {
output: {
minify: {
compress: {
// dropConsole: true,
// dropDebugger: true,
}
}
}
},
rollupOptions: {
output: {
entryFileNames: "js/[name].[hash].js",
chunkFileNames: "js/[name].[hash].js",
assetFileNames: (assetInfo: any) => {
const info = assetInfo.name.split(".");
let extType = info[info.length - 1];
if (/\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/i.test(assetInfo.name)) extType = "media";
else if (/\.(png|jpe?g|gif|svg)(\?.*)?$/i.test(assetInfo.name)) extType = "img";
else if (/\.(woff2?|eot|ttf|otf)(\?.*)?$/i.test(assetInfo.name)) extType = "fonts";
return `${extType}/[name].[hash].[ext]`;
},
},
},
},
})