-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnext.config.js
45 lines (39 loc) · 1.18 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
const path = require('node:path');
/** @type {import('next').NextConfig} */
const nextConfig = {
webpack: (config, { isServer }) => {
config.resolve.fallback = { fs: false, net: false, tls: false };
config.externals.push('pino-pretty', 'lokijs', 'encoding');
if (isServer) {
config.externals.push({
bufferutil: 'bufferutil',
'utf-8-validate': 'utf-8-validate',
});
}
// Grab the existing rule that handles SVG imports
const fileLoaderRule = config.module.rules.find((rule) =>
rule.test?.test?.('.svg'),
);
config.module.rules.push(
{
...fileLoaderRule,
test: /\.svg$/i,
resourceQuery: { not: /inline/ }, // exclude if *.svg?inline
},
{
test: /\.svg$/i,
issuer: /\.[jt]sx?$/,
resourceQuery: /inline/, // *.svg?inline
use: ['@svgr/webpack'],
},
);
// Modify the file loader rule to ignore *.svg, since we have it handled now.
fileLoaderRule.exclude = /\.svg$/i;
config.resolve.alias = {
...config.resolve.alias,
'@/styles': path.resolve(__dirname, 'src/styles'),
};
return config;
},
};
module.exports = nextConfig;