代码拉取完成,页面将自动刷新
/*
* @Date: 2021-11-30 15:42:07
* @LastEditors: 春贰
* @Desc:
* @LastEditTime: 2023-11-06 11:58:23
* @FilePath: \web\vite.config.js
*/
import { resolve } from "path/posix";
import { defineConfig, loadEnv } from "vite";
import vue from "@vitejs/plugin-vue";
import visualizer from "rollup-plugin-visualizer";
import path from "path";
const plugins = [vue()];
//分析插件
if (process.env.vis) {
plugins.push(
visualizer({
open: true,
gzipSize: true,
brotliSize: true
})
);
}
const config = ({ mode }) => {
// console.log(loadEnv(mode, process.cwd()).VITE_PORT);
return defineConfig({
plugins,
base: process.env.ELECTRON == "true" ? "./" : "",
server: {
host: "0.0.0.0",
port: loadEnv(mode, process.cwd()).VITE_PORT
},
resolve: {
extensions: [".js", ".vue", ".json"],
alias: {
"@": path.resolve(__dirname, "src"),
component: path.resolve(__dirname, "src/component"),
img: path.resolve(__dirname, "src/assets/image"),
images: path.resolve(__dirname, "src/assets/image"),
font: path.resolve(__dirname, "src/assets/font")
}
},
// 开启less支持
css: {
preprocessorOptions: {
less: {
javascriptEnabled: true
}
}
},
hmr: {
overlay: true
},
build: {
minify: "terser",
chunkSizeWarningLimit: 1500, // 单个文件大小警告
//清除console
terserOptions: {
compress: {
drop_console: false,
drop_debugger: true
}
},
rollupOptions: {
// output:{
// manualChunks(id){ // 分包
// if(id.includes('node_modules')){
// return id.toString().split('node_modules/')[1].split('/')[0].toString();
// }
// }
// }
}
},
optimizeDeps: {
exclude: ["@antv/x6-vue-shape"] //这玩意一定要加,因为x6 是commonjs
},
define: {
// 定义全局变量 版本号
__VERSION__: JSON.stringify(process.env.npm_package_version)
}
});
};
export default config;
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。