60 lines
1.4 KiB
TypeScript
60 lines
1.4 KiB
TypeScript
import path from "node:path";
|
|
import vue from "@vitejs/plugin-vue";
|
|
import vueJsx from "@vitejs/plugin-vue-jsx";
|
|
import AutoImport from "unplugin-auto-import/vite";
|
|
import { defineConfig } from "vite";
|
|
import Components from "unplugin-vue-components/vite";
|
|
import { DevUiResolver } from "unplugin-vue-components/resolvers";
|
|
|
|
// https://vite.dev/config/
|
|
export default defineConfig({
|
|
base: "/yx",
|
|
server: {
|
|
host: "0.0.0.0",
|
|
port: 5175,
|
|
},
|
|
plugins: [
|
|
vue(),
|
|
vueJsx(),
|
|
AutoImport({
|
|
include: [/\.[tj]sx?$/, /\.vue$/, /\.vue\?vue/],
|
|
imports: ["vue"],
|
|
dirs: ["./src"],
|
|
}),
|
|
Components({
|
|
resolvers: [DevUiResolver()],
|
|
}),
|
|
],
|
|
resolve: {
|
|
alias: {
|
|
"@view": path.resolve(__dirname, "./src/view"),
|
|
"@": path.resolve(__dirname, "./src"),
|
|
},
|
|
},
|
|
build: {
|
|
rollupOptions: {
|
|
output: {
|
|
manualChunks: {
|
|
// 将第三方库拆分成单独的chunk
|
|
vue: ["vue", "vue-router", "pinia"],
|
|
devui: ["vue-devui", "devui-theme"],
|
|
utils: ["dayjs", "uuid", "openai"],
|
|
},
|
|
},
|
|
},
|
|
// 启用代码压缩
|
|
minify: "terser",
|
|
terserOptions: {
|
|
compress: {
|
|
drop_console: true,
|
|
drop_debugger: true,
|
|
},
|
|
},
|
|
|
|
// 拆分CSS文件
|
|
cssCodeSplit: true,
|
|
// 设置chunk大小警告限制
|
|
chunkSizeWarningLimit: 1000,
|
|
},
|
|
});
|