中航光电热表web
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.

93 lines
2.5 KiB

3 weeks ago
import { defineConfig, loadEnv } from "vite";
import { resolve } from "path";
3 months ago
3 weeks ago
import path from "path";
import createVitePlugins from "./vite/plugins";
import { createSvgIconsPlugin } from "vite-plugin-svg-icons";
3 months ago
// https://vitejs.dev/config/
3 weeks ago
export default ({ mode, command }) => {
const env = loadEnv(mode, process.cwd());
const { VITE_APP_ENV, VITE_APP_BASE } = env;
3 months ago
// 判断是打生产环境包
3 weeks ago
const isProd = VITE_APP_ENV === "production";
3 months ago
// 根据是否生产环境,动态设置压缩配置
const buildConfig = {
3 weeks ago
target: "esnext",
minify: isProd ? "terser" : "esbuild", // 根据环境选择压缩工具
3 months ago
};
// 如果是生产环境,添加Terser的配置
if (isProd) {
buildConfig.terserOptions = {
compress: {
drop_console: true, // 删除 console
drop_debugger: true, // 删除 debugger
},
format: {
3 weeks ago
comments: false, // 删除所有注释
},
3 months ago
};
buildConfig.rollupOptions = {
output: {
manualChunks: {
3 weeks ago
"element-plus": ["element-plus"],
"@smallwei/avue": ["@smallwei/avue"],
3 months ago
},
3 weeks ago
},
};
3 months ago
}
return defineConfig({
base: VITE_APP_BASE,
define: {
__VUE_I18N_FULL_INSTALL__: true,
__VUE_I18N_LEGACY_API__: true,
3 weeks ago
__INTLIFY_PROD_DEVTOOLS__: false,
3 months ago
},
server: {
port: 2888,
proxy: {
3 weeks ago
"/api": {
6 days ago
// target: "http://192.168.1.5:82",
3 weeks ago
// target: "http://192.168.1.4:82",
// target:'http://49.232.74.228:82',
6 days ago
target: "http://192.168.0.120",
3 months ago
//target: 'https://saber3.bladex.cn/api',
changeOrigin: true,
3 weeks ago
rewrite: (path) => path.replace(/^\/api/, ""),
3 months ago
},
},
},
resolve: {
alias: {
3 weeks ago
"~": resolve(__dirname, "./"),
"@": resolve(__dirname, "./src"),
components: resolve(__dirname, "./src/components"),
styles: resolve(__dirname, "./src/styles"),
utils: resolve(__dirname, "./src/utils"),
3 months ago
},
},
css: {
preprocessorOptions: {
scss: {
3 weeks ago
api: "modern-compiler",
3 months ago
additionalData: `@use "@/styles/variables.scss" as *;`,
},
},
},
3 weeks ago
plugins: [
createVitePlugins(env, command === "build"),
3 months ago
createSvgIconsPlugin({
3 weeks ago
iconDirs: [path.resolve(process.cwd(), "src/assets/svg")],
symbolId: "icon-[dir]-[name]",
}),
],
3 months ago
build: buildConfig,
optimizeDeps: {
esbuildOptions: {
3 weeks ago
target: "esnext",
3 months ago
},
},
});
};