-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnext.config.mjs
68 lines (59 loc) · 1.57 KB
/
next.config.mjs
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
// next.config.mjs
/** @type {import('next').NextConfig} */
const nextConfig = {
// Enable React Strict Mode for highlighting potential problems
reactStrictMode: true,
// Enable SWC minification for faster builds
swcMinify: true,
webpack(config, { isServer }) {
// Remove the default SVG handling
const fileLoaderRule = config.module.rules.find((rule) =>
rule.test?.test?.(".svg")
);
if (fileLoaderRule) {
fileLoaderRule.exclude = /\.svg$/;
}
// Add custom SVG handling with @svgr/webpack
config.module.rules.push({
test: /\.svg$/,
issuer: {
// Adjust the issuer based on your project structure
and: [/\.(js|ts)x?$/],
},
use: [
{
loader: "@svgr/webpack",
options: {
// SVGR options can be customized here
svgo: true, // Enable SVGO for optimization
svgoConfig: {
plugins: [
{
name: "removeViewBox",
active: false, // Preserve viewBox attribute
},
],
},
titleProp: true, // Enable passing title prop for accessibility
},
},
],
});
return config;
},
};
export default nextConfig;
// webpack(config) {
// config.module.rules.push({
// test: /\.svg$/,
// use: [
// {
// loader: '@svgr/webpack',
// options: {
// svgo: true, // Disable SVGO optimization if you encounter issues
// },
// },
// ],
// });
// return config;
// },