import { defineConfig, loadEnv } from 'vite'; import react from '@vitejs/plugin-react'; import path from 'path'; // const CURRENT_THEME = 'blue'; // 为 mode 参数指定 string 类型 export default ({ mode }: { mode: string }) => { const env = loadEnv(mode, `${process.cwd()}`); // console.log(env, 'shuju111'); // console.log('当前的 mode 参数值:', mode); // console.log('process.cwd():',`${process.cwd()}/src`); const url = env.VITE_CURRENT_THEME || 'mzw' return defineConfig({ plugins: [react()], resolve: { alias: { '@theme': path.resolve(__dirname, `src/static/${url}`) } }, define: { THEME: JSON.stringify(url), }, server: { host: '0.0.0.0' }, base: './', }); };