This noticeably improves performance in the admin panel, for example
when there are multiple richtext editors on one page (& likely
performance in other areas too, though I mainly tested rich text).
The babel plugin currently only optimizes files with a 'use client'
directive at the top - thus we have to make sure to add use client
wherever possible, even if it's imported by a parent client component.
There's one single component that broke when it was compiled using the
React compiler (it stopped being reactive and failed one of our admin
e2e tests):
150808f608
opting out of it completely fixed that issue
Fixes https://github.com/payloadcms/payload/issues/7366
50 lines
1.1 KiB
JavaScript
50 lines
1.1 KiB
JavaScript
import bundleAnalyzer from '@next/bundle-analyzer'
|
|
|
|
import { withPayload } from '@payloadcms/next/withPayload'
|
|
import path from 'path'
|
|
import { fileURLToPath } from 'url'
|
|
|
|
const __filename = fileURLToPath(import.meta.url)
|
|
const dirname = path.dirname(__filename)
|
|
|
|
const withBundleAnalyzer = bundleAnalyzer({
|
|
enabled: process.env.ANALYZE === 'true',
|
|
})
|
|
|
|
// eslint-disable-next-line no-restricted-exports
|
|
export default withBundleAnalyzer(
|
|
withPayload({
|
|
eslint: {
|
|
ignoreDuringBuilds: true,
|
|
},
|
|
typescript: {
|
|
ignoreBuildErrors: true,
|
|
},
|
|
env: {
|
|
PAYLOAD_CORE_DEV: 'true',
|
|
ROOT_DIR: path.resolve(dirname),
|
|
},
|
|
async redirects() {
|
|
return [
|
|
{
|
|
destination: '/admin',
|
|
permanent: true,
|
|
source: '/',
|
|
},
|
|
]
|
|
},
|
|
images: {
|
|
domains: ['localhost'],
|
|
},
|
|
webpack: (webpackConfig) => {
|
|
webpackConfig.resolve.extensionAlias = {
|
|
'.cjs': ['.cts', '.cjs'],
|
|
'.js': ['.ts', '.tsx', '.js', '.jsx'],
|
|
'.mjs': ['.mts', '.mjs'],
|
|
}
|
|
|
|
return webpackConfig
|
|
},
|
|
}),
|
|
)
|