Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

chore: fix load env and treeshaking for vinext (#32928)

Stephen Zhou3bf7bb178154
diff --git a/web/config/index.ts b/web/config/index.ts
index 167c87ae34e..35ea3780a8e 100644
--- a/web/config/index.ts
+++ b/web/config/index.ts
@@ -42,8 +42,8 @@ export const AMPLITUDE_API_KEY = getStringConfig(
'',
)
-export const IS_DEV = env.NODE_ENV === 'development'
-export const IS_PROD = env.NODE_ENV === 'production'
+export const IS_DEV = process.env.NODE_ENV === 'development'
+export const IS_PROD = process.env.NODE_ENV === 'production'
export const SUPPORT_MAIL_LOGIN = env.NEXT_PUBLIC_SUPPORT_MAIL_LOGIN
diff --git a/web/env.ts b/web/env.ts
index f240fcd9805..f931c486770 100644
--- a/web/env.ts
+++ b/web/env.ts
@@ -153,12 +153,8 @@ export const env = createEnv({
*/
TEXT_GENERATION_TIMEOUT_MS: coercedNumber.default(60000),
},
- shared: {
- NODE_ENV: z.enum(['development', 'test', 'production']).default('development'),
- },
client: clientSchema,
experimental__runtimeEnv: {
- NODE_ENV: process.env.NODE_ENV,
NEXT_PUBLIC_ALLOW_EMBED: isServer ? process.env.NEXT_PUBLIC_ALLOW_EMBED : getRuntimeEnvFromBody('allowEmbed'),
NEXT_PUBLIC_ALLOW_UNSAFE_DATA_SCHEME: isServer ? process.env.NEXT_PUBLIC_ALLOW_UNSAFE_DATA_SCHEME : getRuntimeEnvFromBody('allowUnsafeDataScheme'),
NEXT_PUBLIC_AMPLITUDE_API_KEY: isServer ? process.env.NEXT_PUBLIC_AMPLITUDE_API_KEY : getRuntimeEnvFromBody('amplitudeApiKey'),
diff --git a/web/next.config.ts b/web/next.config.ts
index 2236278a74e..591c210fe92 100644
--- a/web/next.config.ts
+++ b/web/next.config.ts
@@ -3,7 +3,7 @@ import createMDX from '@next/mdx'
import { codeInspectorPlugin } from 'code-inspector-plugin'
import { env } from './env'
-const isDev = env.NODE_ENV === 'development'
+const isDev = process.env.NODE_ENV === 'development'
const withMDX = createMDX({
extension: /\.mdx?$/,
options: {
diff --git a/web/package.json b/web/package.json
index e0df37836ee..d3529433286 100644
--- a/web/package.json
+++ b/web/package.json
@@ -31,9 +31,9 @@
"dev:vinext": "vinext dev",
"build": "next build",
"build:docker": "next build && node scripts/optimize-standalone.js",
- "build:vinext": "cross-env NODE_ENV=production vinext build",
+ "build:vinext": "vinext build",
"start": "node ./scripts/copy-and-start.mjs",
- "start:vinext": "cross-env NODE_ENV=production vinext start",
+ "start:vinext": "vinext start",
"lint": "eslint --cache --concurrency=auto",
"lint:ci": "eslint --cache --concurrency 2",
"lint:fix": "pnpm lint --fix",
@@ -247,7 +247,7 @@
"tsx": "4.21.0",
"typescript": "5.9.3",
"uglify-js": "3.19.3",
- "vinext": "https://pkg.pr.new/hyoban/vinext@cfae669",
+ "vinext": "https://pkg.pr.new/hyoban/vinext@a30ba79",
"vite": "8.0.0-beta.16",
"vite-tsconfig-paths": "6.1.1",
"vitest": "4.0.18",
diff --git a/web/pnpm-lock.yaml b/web/pnpm-lock.yaml
index 81ecb7f8574..3251493a135 100644
--- a/web/pnpm-lock.yaml
+++ b/web/pnpm-lock.yaml
@@ -608,8 +608,8 @@ importers:
specifier: 3.19.3
version: 3.19.3
vinext:
- specifier: https://pkg.pr.new/hyoban/vinext@cfae669
+ specifier: https://pkg.pr.new/hyoban/vinext@a30ba79
vite:
specifier: 8.0.0-beta.16
@@ -7727,8 +7727,8 @@ packages:
resolution: {integrity: sha512-KzIbH/9tXat2u30jf+smMwFCsno4wHVdNmzFyL+T/L3UGqqk6JKfVqOFOZEpZSHADH1k40ab6NUIXZq422ov3Q==}
- vinext@https://pkg.pr.new/hyoban/vinext@cfae669:
- resolution: {integrity: sha512-4SRm/Dkou0Ib0UYexP8xg0G83jIM17XPUC32uXwLHt5lO47AisblMpDZXTh84fhN058FEHtPaAGtoFThaoZLIw==, tarball: https://pkg.pr.new/hyoban/vinext@cfae669}
+ vinext@https://pkg.pr.new/hyoban/vinext@a30ba79:
+ resolution: {integrity: sha512-yx/gCneOli5eGTrLUq6/M7A6DGQs14qOJW/Xp9RN6sTI0mErKyWWjO5E7FZT98BJbqH5xzI5nk8EOCLF3bojkA==, tarball: https://pkg.pr.new/hyoban/vinext@a30ba79}
version: 0.0.5
engines: {node: '>=22'}
hasBin: true
@@ -16291,7 +16291,7 @@ snapshots:
'@types/unist': 3.0.3
vfile-message: 4.0.3
dependencies:
'@vercel/og': 0.8.6
diff --git a/web/proxy.ts b/web/proxy.ts
index bc4a4a3d892..8d7c28153e7 100644
--- a/web/proxy.ts
+++ b/web/proxy.ts
@@ -22,7 +22,7 @@ export function proxy(request: NextRequest) {
},
})
- const isWhiteListEnabled = !!env.NEXT_PUBLIC_CSP_WHITELIST && env.NODE_ENV === 'production'
+ const isWhiteListEnabled = !!env.NEXT_PUBLIC_CSP_WHITELIST && process.env.NODE_ENV === 'production'
if (!isWhiteListEnabled)
return wrapResponseWithXFrameOptions(response, pathname)
diff --git a/web/vite.config.ts b/web/vite.config.ts
index a3e1cb77efe..9cfa6a8e7b0 100644
--- a/web/vite.config.ts
+++ b/web/vite.config.ts
@@ -71,10 +71,10 @@ const createForceInspectorClientInjectionPlugin = (): Plugin => {
}
export default defineConfig(({ mode }) => {
- const isDev = mode === 'development'
+ const isTest = mode === 'test'
return {
- plugins: mode === 'test'
+ plugins: isTest
? [
tsconfigPaths(),
react(),
@@ -89,12 +89,8 @@ export default defineConfig(({ mode }) => {
} as Plugin,
]
: [
- ...(isDev
- ? [
- createCodeInspectorPlugin(),
- createForceInspectorClientInjectionPlugin(),
- ]
- : []),
+ createCodeInspectorPlugin(),
+ createForceInspectorClientInjectionPlugin(),
vinext(),
],
resolve: {
@@ -104,7 +100,7 @@ export default defineConfig(({ mode }) => {
},
// vinext related config
- ...(mode !== 'test'
+ ...(!isTest
? {
optimizeDeps: {
exclude: ['nuqs'],