feat(vite-plugins): 更新cloudflare插件环境变量加载方式
This commit is contained in:
@@ -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 [];
|
||||
}
|
||||
|
||||
@@ -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'],
|
||||
|
||||
Reference in New Issue
Block a user