-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathnext.config.js
81 lines (74 loc) · 1.89 KB
/
next.config.js
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
const isProd = process.env.NEXT_PUBLIC_RUNTIME_ENV === 'production'
const isLocal = process.env.NEXT_PUBLIC_RUNTIME_ENV === 'local'
const nextAssetDomain = process.env.NEXT_PUBLIC_NEXT_ASSET_DOMAIN || ''
/**
* @type {import('next').NextConfig}
*/
const nextConfig = {
/**
* Build time configs
*/
assetPrefix: nextAssetDomain ? `https://${nextAssetDomain}` : undefined,
pageExtensions: ['tsx'],
webpack(config, { defaultLoaders, isServer }) {
config.module.rules.push({
test: /\.svg$/,
use: [
{
loader: '@svgr/webpack',
options: {
svgoConfig: {
plugins: [
{
name: 'removeViewBox',
active: false,
},
{
name: 'removeDimensions',
active: true,
},
{
name: 'prefixIds',
active: true,
},
],
},
},
},
{
loader: 'url-loader',
options: {
limit: 1024,
publicPath: nextAssetDomain
? `https://${nextAssetDomain}/_next/static/`
: '/_next/static/',
outputPath: `${isServer ? '../' : ''}static/`,
},
},
],
})
return config
},
/**
* Runtime configs
*
*/
reactStrictMode: true,
compress: false,
poweredByHeader: false,
}
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
})
const withPWA = require('next-pwa')({
dest: 'public',
disable: isLocal,
register: true,
sw: 'service-worker.js',
runtimeCaching: [], // disable runtime caching
publicExcludes: ['!static/**/*'],
buildExcludes: [/.*\.svg/],
cacheStartUrl: false,
dynamicStartUrl: true,
})
module.exports = withPWA(withBundleAnalyzer(nextConfig))