-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnext.config.mjs
142 lines (134 loc) · 3.73 KB
/
next.config.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
import withBundleAnalyzer from '@next/bundle-analyzer'
// import { withContentlayer } from 'next-contentlayer'
import nextMDX from '@next/mdx'
import createNextIntlPlugin from 'next-intl/plugin'
// import { createSecureHeaders } from 'next-secure-headers'
import { recmaPlugins } from './src/mdx/recma.mjs'
import { rehypePlugins } from './src/mdx/rehype.mjs'
import { remarkPlugins } from './src/mdx/remark.mjs'
import withSearch from './src/mdx/search.mjs'
/**
* Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially useful
* for Docker builds.
*/
// import './src/env.mjs'
// equivalent to
await import('./src/env.mjs')
const withNextIntl = createNextIntlPlugin('./src/i18n.ts')
const bundleAnalyzer = withBundleAnalyzer({
enabled: process.env.ANALYZE === 'true'
})
const withMDX = nextMDX({
options: {
remarkPlugins,
// @ts-expect-error
rehypePlugins,
recmaPlugins
}
})
/**
* @typedef {import('next').NextConfig} NextConfig
* @typedef {Array<((config: NextConfig) => NextConfig)>} NextConfigPlugins
*/
/** @type {NextConfigPlugins} */
// const plugins = []
/** @type {NextConfig} */
const nextConfig = {
pageExtensions: ['js', 'jsx', 'ts', 'tsx', 'mjs', 'mdx'],
eslint: {
dirs: ['.'],
ignoreDuringBuilds: true
},
// compress: false,
// swcMinify: true,
cleanDistDir: true,
poweredByHeader: false,
reactStrictMode: true,
experimental: {
// Related to Pino error with RSC: https://github.com/orgs/vercel/discussions/3150
serverComponentsExternalPackages: ['pino']
},
// https://nextjs.org/docs/messages/next-image-unconfigured-host
images: {
dangerouslyAllowSVG: true,
remotePatterns: [
{
protocol: 'https',
hostname: 'yangtze.zeabur.app',
port: '',
pathname: '/images/**'
},
{
protocol: 'https',
hostname: 'cn.bing.com',
port: '',
pathname: '/th**'
},
{
protocol: 'https',
hostname: 'yet-another-react-lightbox.com',
port: '',
pathname: '/images/**'
},
{
protocol: 'https',
hostname: 'images.unsplash.com',
port: '',
pathname: '/**'
},
{
protocol: 'https',
hostname: 'cdn.beekka.com',
port: '',
pathname: '/blogimg/**'
}
]
},
// output: 'standalone',
// output: process.env.NEXT_OUTPUT_MODE,
/**
*
* @param {import('webpack').Configuration} config
* @param {import('next/dist/server/config-shared').WebpackConfigContext} context
* @returns {import('webpack').Configuration}
*/
webpack: (config, context) => {
// if (process.env.NEXT_OUTPUT_MODE !== 'export' || !config.module) {
// return config
// }
// const { isServer } = context
// if (!isServer) {
// config.resolve.fallback.fs = false
// }
// config.externals is needed to resolve the following errors:
// Module not found: Can't resolve 'bufferutil'
// Module not found: Can't resolve 'utf-8-validate'
// @ts-ignore
config.externals.push({
'bufferutil': 'bufferutil',
'utf-8-validate': 'utf-8-validate'
})
// config.optimization.minimize = false
// NOTE: ignore python files
// @ts-ignore
config.module.rules.push({
test: /\.py$/,
loader: 'ignore-loader'
})
return config
}
}
// plugins.push(
// nextMDX({
// options: {
// remarkPlugins,
// rehypePlugins,
// recmaPlugins
// }
// })
// )
// export default () => plugins.reduce((_, plugin) => plugin(_), nextConfig)
export default bundleAnalyzer(withNextIntl(withSearch(withMDX(nextConfig))))
// export default bundleAnalyzer(
// withNextIntl(withSearch(withContentlayer(withMDX(nextConfig))))
// )