INIT
This commit is contained in:
72
vite.config.ts
Normal file
72
vite.config.ts
Normal file
@@ -0,0 +1,72 @@
|
||||
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 viteCompression from "vite-plugin-compression";
|
||||
import Components from "unplugin-vue-components/vite";
|
||||
import { DevUiResolver } from "unplugin-vue-components/resolvers";
|
||||
|
||||
// https://vite.dev/config/
|
||||
export default defineConfig({
|
||||
base: "/ai",
|
||||
server: {
|
||||
host: "0.0.0.0",
|
||||
port: 5173,
|
||||
},
|
||||
plugins: [
|
||||
vue(),
|
||||
vueJsx(),
|
||||
AutoImport({
|
||||
include: [/\.[tj]sx?$/, /\.vue$/, /\.vue\?vue/],
|
||||
imports: ["vue"],
|
||||
dirs: ["./src"],
|
||||
}),
|
||||
// 配置 gzip 压缩插件
|
||||
viteCompression({
|
||||
algorithm: "gzip", // 使用 gzip 压缩
|
||||
ext: ".gz", // 压缩文件扩展名
|
||||
threshold: 10240, // 只有大于 10 KB 的文件才会被压缩
|
||||
deleteOriginFile: false, // 不删除源文件
|
||||
}),
|
||||
Components({
|
||||
resolvers: [DevUiResolver()],
|
||||
}),
|
||||
],
|
||||
resolve: {
|
||||
alias: {
|
||||
"@view": path.resolve(__dirname, "./src/view"),
|
||||
"@": path.resolve(__dirname, "./src"),
|
||||
},
|
||||
},
|
||||
build: {
|
||||
rollupOptions: {
|
||||
output: {
|
||||
// 代码分割配置
|
||||
manualChunks: {
|
||||
// 将大型依赖库分离到单独的chunk中
|
||||
"vue-vendor": ["vue", "vue-router", "pinia"],
|
||||
"markdown-vendor": [
|
||||
"markdown-it",
|
||||
"markdown-it-emoji",
|
||||
"@mdit/plugin-katex",
|
||||
"katex",
|
||||
],
|
||||
"ui-vendor": ["vue-devui"],
|
||||
"theme-vendor": ["devui-theme"],
|
||||
"chart-vendor": ["mermaid"],
|
||||
"utils-vendor": ["axios", "dayjs", "uuid"],
|
||||
},
|
||||
},
|
||||
},
|
||||
// 启用terser压缩
|
||||
minify: "terser",
|
||||
terserOptions: {
|
||||
compress: {
|
||||
// 移除console和debugger
|
||||
drop_console: true,
|
||||
drop_debugger: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
Reference in New Issue
Block a user