mirror of https://github.com/langgenius/dify.git
refactor(web): optimize React Scan loading with dynamic import
Replace static import of React Scan with next/dynamic + ssr:false in layout.tsx. This ensures React Scan code is excluded from the server-side bundle and only loaded in development, improving production performance.
This commit is contained in:
parent
6b4ac79f08
commit
7c8b58167f
|
|
@ -1,6 +1,8 @@
|
|||
import type { Viewport } from 'next'
|
||||
import { ThemeProvider } from 'next-themes'
|
||||
import dynamic from 'next/dynamic'
|
||||
import { Instrument_Serif } from 'next/font/google'
|
||||
import { IS_DEV } from '@/config'
|
||||
import GlobalPublicStoreProvider from '@/context/global-public-context'
|
||||
import { TanstackQueryInitializer } from '@/context/query-client'
|
||||
import { getLocaleOnServer } from '@/i18n-config/server'
|
||||
|
|
@ -8,12 +10,15 @@ import { DatasetAttr } from '@/types/feature'
|
|||
import { cn } from '@/utils/classnames'
|
||||
import BrowserInitializer from './components/browser-initializer'
|
||||
import I18nServer from './components/i18n-server'
|
||||
import { ReactScan } from './components/react-scan'
|
||||
import SentryInitializer from './components/sentry-initializer'
|
||||
import RoutePrefixHandle from './routePrefixHandle'
|
||||
import './styles/globals.css'
|
||||
import './styles/markdown.scss'
|
||||
|
||||
const ReactScan = IS_DEV
|
||||
? dynamic(() => import('./components/react-scan').then(m => m.ReactScan), { ssr: false })
|
||||
: () => null
|
||||
|
||||
export const viewport: Viewport = {
|
||||
width: 'device-width',
|
||||
initialScale: 1,
|
||||
|
|
|
|||
Loading…
Reference in New Issue