-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathnext.config.js
96 lines (89 loc) · 2.7 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
93
94
95
96
/* eslint-disable @typescript-eslint/no-var-requires */
const path = require('path')
const { createLoader } = require('simple-functional-loader')
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true'
})
const runtimeCaching = require('next-pwa/cache')
const withPWA = require('next-pwa')({
dest: 'public',
runtimeCaching,
disable: process.env.NODE_ENV === 'development'
})
const withMDX = require('@next/mdx')({
extension: /\.mdx?$/,
options: {
remarkPlugins: [],
rehypePlugins: [],
// If you use `MDXProvider`, uncomment the following line.
providerImportSource: '@mdx-js/react'
}
})
/** @type {import('next').NextConfig} */
const nextConfig = withBundleAnalyzer(
withPWA(
withMDX({
swcMinify: true,
reactStrictMode: true,
images: {
disableStaticImages: true
},
experimental: { esmExternals: true },
pageExtensions: ['js', 'jsx', 'ts', 'tsx', 'md', 'mdx'],
webpack: (
config,
{ buildId, dev, isServer, defaultLoaders, webpack }
) => {
defaultLoaders.babel.options.cache = false
config.resolve.modules.push(path.resolve('./'))
// file-loader config
config.module.rules.push({
test: /\.(jpe?g|png|svg|gif|ico|eot|ttf|woff|woff2|mp4|pdf|webp|txt)$/i,
issuer: /\.(jsx?|tsx?|mdx?)$/,
use: [
{
loader: 'file-loader',
options: {
esModule: false,
publicPath: '/_next',
name: 'static/media/[name].[hash].[ext]'
}
}
]
})
// embeding svg as react component
config.module.rules.push({
test: /\.svg$/,
use: [
{
loader: '@svgr/webpack',
options: { svgoConfig: { plugins: { removeViewBox: false } } }
},
{
loader: 'file-loader',
options: {
publicPath: '/_next',
name: 'static/media/[name].[hash].[ext]'
}
}
]
})
// Remove the 3px deadzone for drag gestures in Framer Motion
config.module.rules.push({
test: /framer-motion/,
use: createLoader(function (source) {
return source.replace(
/var isDistancePastThreshold = .*?$/m,
'var isDistancePastThreshold = true'
)
})
})
return config
},
async redirects() {
return require('./redirects.json')
}
})
)
)
module.exports = nextConfig