2024-09-18 16:51:45 +07:00
|
|
|
/** @type {import('next').NextConfig} */
|
2025-02-10 13:32:34 +07:00
|
|
|
|
2026-04-01 22:24:07 +01:00
|
|
|
const nextConfig = ({
|
2024-09-18 16:51:45 +07:00
|
|
|
reactStrictMode: true,
|
|
|
|
|
webpack: (config) => {
|
|
|
|
|
const fileLoaderRule = config.module.rules.find((rule) =>
|
|
|
|
|
rule.test?.test?.(".svg")
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
config.module.rules.push(
|
|
|
|
|
// Reapply the existing rule, but only for svg imports ending in ?url
|
|
|
|
|
{
|
|
|
|
|
...fileLoaderRule,
|
|
|
|
|
test: /\.svg$/i,
|
2025-02-10 13:32:34 +07:00
|
|
|
resourceQuery: /url/, // *.svg?url
|
2024-09-18 16:51:45 +07:00
|
|
|
},
|
|
|
|
|
// Convert all other *.svg imports to React components
|
|
|
|
|
{
|
|
|
|
|
test: /\.svg$/i,
|
|
|
|
|
issuer: fileLoaderRule.issuer,
|
|
|
|
|
resourceQuery: { not: [...fileLoaderRule.resourceQuery.not, /url/] }, // exclude if *.svg?url
|
2024-09-21 03:43:02 +07:00
|
|
|
use: [
|
|
|
|
|
{
|
|
|
|
|
loader: '@svgr/webpack',
|
|
|
|
|
options: {
|
|
|
|
|
svgoConfig: {
|
|
|
|
|
plugins: {
|
|
|
|
|
removeViewBox: false
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
],
|
2024-09-18 16:51:45 +07:00
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
2024-09-21 03:43:02 +07:00
|
|
|
fileLoaderRule.exclude = /\.svg$/i;
|
|
|
|
|
|
2024-09-18 16:51:45 +07:00
|
|
|
return config;
|
|
|
|
|
},
|
2025-02-10 13:32:34 +07:00
|
|
|
});
|
2024-09-18 16:51:45 +07:00
|
|
|
|
|
|
|
|
export default nextConfig;
|