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