chore: disable serwist in dev

This commit is contained in:
Stephen Zhou
2026-01-23 11:11:39 +08:00
parent c8ae6e39d2
commit 00ec2c2623
2 changed files with 20 additions and 7 deletions

View File

@ -1,3 +1,19 @@
'use client'
export { SerwistProvider } from '@serwist/turbopack/react'
import { SerwistProvider } from '@serwist/turbopack/react'
import { IS_DEV } from '@/config'
export function PWAProvider({ children }: { children: React.ReactNode }) {
const basePath = process.env.NEXT_PUBLIC_BASE_PATH || ''
const swUrl = `${basePath}/serwist/sw.js`
if (IS_DEV) {
return <>{children}</>
}
return (
<SerwistProvider swUrl={swUrl}>
{children}
</SerwistProvider>
)
}

View File

@ -12,7 +12,7 @@ import { ToastProvider } from './components/base/toast'
import BrowserInitializer from './components/browser-initializer'
import { ReactScanLoader } from './components/devtools/react-scan/loader'
import { I18nServerProvider } from './components/provider/i18n-server'
import { SerwistProvider } from './components/provider/serwist'
import { PWAProvider } from './components/provider/serwist'
import SentryInitializer from './components/sentry-initializer'
import RoutePrefixHandle from './routePrefixHandle'
import './styles/globals.css'
@ -40,9 +40,6 @@ const LocaleLayout = async ({
}) => {
const locale = await getLocaleOnServer()
const basePath = process.env.NEXT_PUBLIC_BASE_PATH || ''
const swUrl = `${basePath}/serwist/sw.js`
const datasetMap: Record<DatasetAttr, string | undefined> = {
[DatasetAttr.DATA_API_PREFIX]: process.env.NEXT_PUBLIC_API_PREFIX,
[DatasetAttr.DATA_PUBLIC_API_PREFIX]: process.env.NEXT_PUBLIC_PUBLIC_API_PREFIX,
@ -96,7 +93,7 @@ const LocaleLayout = async ({
className="color-scheme h-full select-auto"
{...datasetMap}
>
<SerwistProvider swUrl={swUrl}>
<PWAProvider>
<ReactScanLoader />
<JotaiProvider>
<ThemeProvider
@ -124,7 +121,7 @@ const LocaleLayout = async ({
</ThemeProvider>
</JotaiProvider>
<RoutePrefixHandle />
</SerwistProvider>
</PWAProvider>
</body>
</html>
)