-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.config.js
88 lines (84 loc) · 2.46 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
const withPlugins = require('next-compose-plugins');
const withBundleAnalyzer = require('@next/bundle-analyzer');
const withMDX = require("@next/mdx")({ extension: /\.mdx?$/ });
const bundleAnalyzer = withBundleAnalyzer({ enabled: process.env.ANALYZE === 'true' });
const mdx = withMDX({ pageExtensions: ["js", "jsx", "md", "mdx"] });
const devMode = process.env.NODE_ENV === 'development' ? true : false;
const nextConfig = {
reactStrictMode: true,
env: {
STRIPE_PRIVATE_KEY: process.env.STRIPE_PRIVATE_KEY,
STRIPE_PUBLIC_KEY: process.env.STRIPE_PUBLIC_KEY,
MONGODB_URI: process.env.MONGODB_URI,
SENDGRID_TEMPLATE: process.env.SENDGRID_TEMPLATE,
SENDGRID: process.env.SENDGRID_TEMPLATE,
URL: process.env.URL,
CRYPTO_SECRET_KEY: process.env.CRYPTO_SECRET_KEY,
CRYPTO_SECRET_IV: process.env.CRYPTO_SECRET_IV,
QRNG_API_KEY: process.env.QRNG_API_KEY,
JWT_SECRET: process.env.JWT_SECRET,
RANDOM_ORG_API_KEY: process.env.RANDOM_ORG_API_KEY,
RANDOM_ORG_HAPI_KEY: process.env.RANDOM_ORG_HAPI_KEY,
},
swcMinify: true,
compiler: {
removeConsole: !devMode,
},
experimental: {
fontLoaders: [
{ loader: '@next/font/google', options: { subsets: ['latin'] } },
],
},
images: {
loader: 'akamai',
path: '',
},
webpack(config, options) {
const { isServer } = options;
if (!isServer) {
// don't resolve 'fs' module on the client to prevent this error on build --> Error: Can't resolve 'fs'
config.resolve.fallback = {
fs: false
}
}
config.module.rules.push({
test: /\.(ogg|mp3|wav|mpe?g)$/i,
exclude: config.exclude,
use: [
{
loader: require.resolve('url-loader'),
options: {
limit: config.inlineImageLimit,
fallback: require.resolve('file-loader'),
publicPath: `${config.assetPrefix}/_next/static/images/`,
outputPath: `${isServer ? '../' : ''}static/images/`,
name: '[name]-[hash].[ext]',
esModule: config.esModule || false,
},
},
],
},
{
test: /\.txt$/i,
use: [
{
loader: 'raw-loader',
options: {
esModule: false,
},
},
],
},);
return config;
},
async redirects() {
return [
{
source: '/qr',
destination: '/',
permanent: false,
},
]
}
}
module.exports = withPlugins([[bundleAnalyzer], [mdx]], nextConfig);