-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.config.js
92 lines (83 loc) · 2.07 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
85
86
87
88
89
90
91
92
const { withContentlayer } = require('next-contentlayer')
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
})
const webpack = require('webpack')
let config = {
optimizeFonts: true,
reactStrictMode: true,
poweredByHeader: false,
typescript: {
ignoreBuildErrors: true,
},
experimental: {
externalDir: true,
},
compiler: {},
async redirects() {
return [
{
source: '/docs/core/overview',
destination: '/docs',
permanent: true,
},
{
source: '/docs/introduction',
destination: '/docs',
permanent: true,
},
{
source: '/docs/core/getting-started',
destination: '/docs/core/quickstarts',
permanent: true,
},
{
source: '/docs/components/data-display/list',
destination: '/docs/components/data-display/structured-list',
permanent: true,
},
]
},
webpack: (config, { defaultLoaders }) => {
const fileLoaderRule = config.module.rules.find(
(rule) => rule.test && rule.test.test('.svg')
)
fileLoaderRule.exclude = /\.svg$/
config.module.rules.push({
test: /\.(png|jpe?g|gif|mp4)$/i,
use: [
{
loader: 'file-loader',
options: {
publicPath: '/_next',
name: 'static/media/[name].[hash].[ext]',
},
},
],
})
config.module.rules.push(
// Reapply the existing rule, but only for svg imports ending in ?url
{
...fileLoaderRule,
test: /\.svg$/i,
resourceQuery: /url/, // *.svg?url
},
// Convert all other *.svg imports to React components
{
test: /\.svg$/i,
issuer: /\.[jt]sx?$/,
resourceQuery: { not: /url/ }, // exclude if *.svg?url
use: ['@svgr/webpack'],
}
)
config.resolve = {
...config.resolve,
}
return config
},
}
const isNextDev = process.argv.includes('dev')
if (isNextDev) {
config = withContentlayer(config)
}
module.exports = withBundleAnalyzer(config)