You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
76 lines
2.0 KiB
76 lines
2.0 KiB
import { defineConfig, loadEnv } from "vite";
|
|
import vue from "@vitejs/plugin-vue";
|
|
import vueJsx from "@vitejs/plugin-vue-jsx";
|
|
import viteCompression from "vite-plugin-compression";
|
|
import { ViteImageOptimizer } from "vite-plugin-image-optimizer";
|
|
import { visualizer } from "rollup-plugin-visualizer";
|
|
import { createHtmlPlugin } from "vite-plugin-html";
|
|
|
|
import path, { resolve } from "path";
|
|
|
|
|
|
const getViteEnv = (mode: string, target: string) => {
|
|
return loadEnv(mode, process.cwd())[target];
|
|
};
|
|
|
|
// https://vitejs.dev/config/
|
|
export default defineConfig(({ mode }) => ({
|
|
base: "./",
|
|
server: {
|
|
host: "0.0.0.0",
|
|
port: 9527,
|
|
open: true,
|
|
},
|
|
plugins: [
|
|
vue(),
|
|
vueJsx(),
|
|
visualizer(),
|
|
// viteCompression(),
|
|
// ViteImageOptimizer(),
|
|
createHtmlPlugin({
|
|
inject: {
|
|
data: {
|
|
//将环境变量 VITE_APP_TITLE 赋值给 title 方便 html页面使用 title 获取系统标题
|
|
title: getViteEnv(mode, "VITE_TITLE"),
|
|
},
|
|
},
|
|
}),
|
|
],
|
|
resolve: {
|
|
alias: {
|
|
"@": resolve(__dirname, "./src"),
|
|
"vue-i18n": "vue-i18n/dist/vue-i18n.cjs.js",
|
|
},
|
|
},
|
|
build: {
|
|
target: "es2015",
|
|
minify: "esbuild",
|
|
outDir: "dist",
|
|
assetsInlineLimit: 2000,
|
|
reportCompressedSize: true,
|
|
chunkSizeWarningLimit: 1500,
|
|
rollupOptions: {
|
|
output: {
|
|
manualChunks: {
|
|
vue: ["vue", "pinia", "vue-router"],
|
|
"element-plus": ["element-plus", "@element-plus/icons-vue"],
|
|
"excel-export": ["table-excel"],
|
|
},
|
|
// Static resource classification and packaging
|
|
chunkFileNames: "assets/js/[name]-[hash].js",
|
|
entryFileNames: "assets/js/[name]-[hash].js",
|
|
assetFileNames: "assets/[ext]/[name]-[hash].[ext]",
|
|
},
|
|
},
|
|
},
|
|
assetsInclude: ["**/*.xlsx"],
|
|
optimizeDeps: {
|
|
include: [
|
|
"vue",
|
|
"vue-router",
|
|
"pinia",
|
|
"element-plus",
|
|
"@element-plus/icons-vue",
|
|
],
|
|
},
|
|
}));
|
|
|