From dd97b96b272019d8729db327dda17508c3aa5446 Mon Sep 17 00:00:00 2001 From: chenbin <174628620@qq.com> Date: Fri, 16 Oct 2026 01:36:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20cdn=20=E7=BC=96=E8=AF=91?= =?UTF-8?q?=E5=90=8E=E7=9A=84=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vite.config.ts | 56 +++++++++++++++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 23 deletions(-) diff --git a/vite.config.ts b/vite.config.ts index e2b5a01..253e52a 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -4,30 +4,40 @@ import { defineConfig } from 'vite' import vue from '@vitejs/plugin-vue' import vueDevTools from 'vite-plugin-vue-devtools' -import vueJsx from '@vitejs/plugin-vue-jsx'; -import { babel } from '@rollup/plugin-babel'; +import vueJsx from '@vitejs/plugin-vue-jsx' +import { babel } from '@rollup/plugin-babel' // https://vite.dev/config/ -export default defineConfig({ - plugins: [ - vue(), - vueDevTools(), - babel({ - plugins: [ - [ - '@babel/plugin-transform-react-jsx', - { - runtime: 'automatic', - importSource: '@antv/f2', - }, +export default defineConfig(({ command }) => { + // 生产构建时指向 CDN 地址,开发时保持 '/' + const base = command === 'build' + ? 'https://images.health.ufutx.com/uftx_case' + : '/' + console.log('base', base) + return { + base, + + plugins: [ + vue(), + vueDevTools(), + babel({ + plugins: [ + [ + '@babel/plugin-transform-react-jsx', + { + runtime: 'automatic', + importSource: '@antv/f2', + }, + ], ], - ], - }), - vueJsx(), - ], - resolve: { - alias: { - '@': fileURLToPath(new URL('./src', import.meta.url)), + }), + vueJsx(), + ], + + resolve: { + alias: { + '@': fileURLToPath(new URL('./src', import.meta.url)), + }, }, - }, -}) + } +}) \ No newline at end of file