-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnext.config.mjs
88 lines (78 loc) · 1.72 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
// @ts-check
import { withSentryConfig } from '@sentry/nextjs'
import PWA from 'next-pwa'
// import runtimeCaching from 'next-pwa/cache'
import bundleAnalyzer from '@next/bundle-analyzer'
const withBundleAnalyzer = bundleAnalyzer({
enabled: process.env.ANALYZE === 'true',
})
const withPWA = PWA({
dest: 'public',
register: true,
skipWaiting: true,
maximumFileSizeToCacheInBytes: 10 * 1024 * 1024,
})
/**
* @type {import('next').NextConfig}
**/
let config = {
webpack(config, context) {
config.experiments = { ...config.experiments, topLevelAwait: true }
config.module.rules.push({
test: /\.ya?ml$/,
use: [
{
loader: 'yaml-loader',
},
],
})
return config
},
reactStrictMode: true,
// transpilePackages: ['d3'],
images: {
remotePatterns: [
{
protocol: 'https',
hostname: 'avatars.githubusercontent.com',
},
{
protocol: 'https',
hostname: 'pbs.twimg.com',
},
],
},
modularizeImports: {
'@/components': {
transform: '@/components/{{member}}',
},
},
}
const plugins = [
{
plugin: withPWA,
env: ['production'],
name: 'PWA',
},
{
name: 'Sentry',
plugin: withSentryConfig,
env: ['production'],
options: [
{},
{
hideSourceMaps: false,
},
],
},
{ name: 'Bundle Analyzer', plugin: withBundleAnalyzer },
]
console.log('ANALYZE', process.env.ANALYZE === 'true')
for (const plug of plugins) {
if (!plug.env || plug.env.includes(process.env.NODE_ENV)) {
console.log('applying plugin', plug.name)
if (plug.options) config = plug.plugin(config, ...plug.options)
else config = plug.plugin(config)
}
}
export default config