| | |
| | | import path from 'path' |
| | | import createVitePlugins from './vite/plugins' |
| | | |
| | | const baseUrl = 'http://localhost:8080' // 后端接口 |
| | | |
| | | // https://vitejs.dev/config/ |
| | | export default defineConfig(({ mode, command }) => { |
| | | const env = loadEnv(mode, process.cwd()) |
| | | const { VITE_APP_ENV } = env |
| | | // 后端接口:默认打内网共享服务,本地起后端时用 VITE_APP_PROXY_TARGET 覆盖 |
| | | const baseUrl = env.VITE_APP_PROXY_TARGET || 'http://192.168.0.24:9509/lims' |
| | | return { |
| | | // 部署生产环境和开发环境下的URL。 |
| | | // 默认情况下,vite 会假设你的应用是被部署在一个域名的根路径上 |
| | |
| | | // https://cn.vitejs.dev/config/#resolve-extensions |
| | | extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue'] |
| | | }, |
| | | // Web Worker 配置:src/workers/*.worker.js 内部 import 了 big.js, |
| | | // 打包成默认的 iife 格式会因代码分割报错,必须用 es 格式 |
| | | worker: { |
| | | format: 'es' |
| | | }, |
| | | // 依赖预构建入口。 |
| | | // 默认策略会把 public/ 下的 ie.html、luckysheet 的 demo_index.html 当成入口, |
| | | // 这些文件引用的都是 UMD 全局脚本,扫描毫无意义。 |
| | | // 但不能只留 index.html:路由页面是动态 import 的,只扫 index.html 会让 |
| | | // splitpanes / jspdf / @vue-office/* / echarts 这类"首次进入某个页面才加载"的依赖 |
| | | // 在运行中被发现,触发一次强制 reload。而 reload 与页面渲染竞态时, |
| | | // 会出现新旧两个 hash 的 chunk 同时存在,表现为 |
| | | // "renderSlot: Cannot read properties of null (reading 'ce')" 这种假崩溃。 |
| | | // 所以明确把 src 纳入扫描面,一次性把依赖找齐。 |
| | | optimizeDeps: { |
| | | entries: ['index.html', 'src/**/*.{js,vue}'] |
| | | }, |
| | | // 打包配置 |
| | | build: { |
| | | // https://vite.dev/config/build-options.html |