From c27c8544de1b2610f7cb55b53796832847ebbb9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=A5=E6=B5=A9?= Date: Mon, 27 Oct 2025 02:25:33 +0800 Subject: [PATCH] =?UTF-8?q?feat(vite-plugins):=20=E6=9B=B4=E6=96=B0cloudfl?= =?UTF-8?q?are=E6=8F=92=E4=BB=B6=E7=8E=AF=E5=A2=83=E5=8F=98=E9=87=8F?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vite-plugins/100.cloudflare.ts | 6 +++--- vite.config.ts | 2 -- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/vite-plugins/100.cloudflare.ts b/vite-plugins/100.cloudflare.ts index 672ac16..f78c93f 100644 --- a/vite-plugins/100.cloudflare.ts +++ b/vite-plugins/100.cloudflare.ts @@ -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 []; } diff --git a/vite.config.ts b/vite.config.ts index 656b31e..2bcf18b 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -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'],