-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnext.config.js
84 lines (76 loc) Β· 2 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
82
83
84
/** @typedef {import('next').NextConfig} NextConfig */
const isProd = process.env.NODE_ENV === 'production'
const removeConsole = isProd ? { exclude: ['error', 'warn'] } : false
/** @type {NextConfig} */
const nextConfig = {
reactStrictMode: true,
eslint: {
ignoreDuringBuilds: true,
},
compiler: {
emotion: true,
removeConsole,
},
images: {
unoptimized: true,
},
modularizeImports: {
'react-iconsax-icons': {
transform: 'react-iconsax-icons/lib/{{member}}',
skipDefaultConversion: true,
},
},
}
/** @type {(nextConfig: NextConfig) => NextConfig} */
const withSvgr = (nextConfig = {}) => {
return {
...nextConfig,
webpack(config, options) {
const urlLoader = {}
const nextImageLoader = config.module.rules.find(
(rule) => rule.loader === 'next-image-loader'
)
if (nextImageLoader) {
urlLoader.loader = nextImageLoader.loader
urlLoader.options = nextImageLoader.options
}
const svgrLoader = {
loader: '@svgr/webpack',
options: {
typescript: true,
titleProp: true,
exportType: 'named',
replaceAttrValues: {
'#000': '{props.color || `#000`}',
'#000000': '{props.color || `#000`}',
},
svgProps: {
fill: 'currentcolor',
},
},
}
config.module.rules.push({
test: /\.svg$/,
rules: [
{
issuer: /\.[jt]sx?$/,
use: [svgrLoader],
},
{
dependency: nextImageLoader?.dependency ?? { not: ['url'] },
issuer: nextImageLoader?.issuer ?? { not: /\.(css|scss|sass)$/ },
use: [urlLoader],
},
],
})
if (typeof nextConfig.webpack === 'function') {
return nextConfig.webpack(config, options)
}
return config
},
}
}
module.exports = () => {
const plugins = [withSvgr]
return plugins.reduce((acc, plugin) => plugin(acc), nextConfig)
}