feat(vite-plugins): 更新cloudflare插件环境变量加载方式

This commit is contained in:
严浩
2025-10-27 02:25:33 +08:00
parent 62a792b1da
commit c27c8544de
2 changed files with 3 additions and 5 deletions

View File

@@ -1,13 +1,13 @@
import { cloudflare } from '@cloudflare/vite-plugin';
import type { ConfigEnv, PluginOption } from 'vite';
import { loadEnv, type ConfigEnv, type PluginOption } from 'vite';
export function loadPlugin(_configEnv: ConfigEnv): PluginOption {
const env = loadEnv(_configEnv.mode, process.cwd());
if (_configEnv.mode === 'test') {
console.log('cloudflare plugin disabled in test mode');
return [];
}
if (process.env.VITE_CLOUDFLARE_SERVER_ENABLED !== 'true') {
if (env.VITE_CLOUDFLARE_SERVER_ENABLED !== 'true') {
console.log('cloudflare plugin disabled by env');
return [];
}

View File

@@ -39,8 +39,6 @@ export default defineConfig(async (configEnv) => {
},
define: {
__DEV__: JSON.stringify(!isBuild),
// // https://github.com/fi3ework/vite-plugin-checker/issues/569#issuecomment-3254311799
// 'process.env.NODE_ENV': JSON.stringify('production'),
},
server: {
allowedHosts: ['.NWCT.DEV'],