MCPcopy Create free account
hub / github.com/chiragksharma/BuildFast / webpack

Function webpack

next.config.mjs:3–29  ·  view source on GitHub ↗
(config)

Source from the content-addressed store, hash-verified

1/** @type {import('next').NextConfig} */
2const nextConfig = {
3 webpack(config) {
4 // Grab the existing rule that handles SVG imports
5 const fileLoaderRule = config.module.rules.find((rule) =>
6 rule.test?.test?.(".svg")
7 );
8
9 config.module.rules.push(
10 // Reapply the existing rule, but only for svg imports ending in ?url
11 {
12 ...fileLoaderRule,
13 test: /\.svg$/i,
14 resourceQuery: /url/, // *.svg?url
15 },
16 // Convert all other *.svg imports to React components
17 {
18 test: /\.svg$/i,
19 issuer: fileLoaderRule.issuer,
20 resourceQuery: { not: [...fileLoaderRule.resourceQuery.not, /url/] }, // exclude if *.svg?url
21 use: ["@svgr/webpack"],
22 }
23 );
24
25 // Modify the file loader rule to ignore *.svg, since we have it handled now.
26 fileLoaderRule.exclude = /\.svg$/i;
27
28 return config;
29 },
30};
31
32export default nextConfig;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected