From e9c97c18994a5e587bd3efc6431e2dbc13f32ad0 Mon Sep 17 00:00:00 2001 From: Spencer Elliott Date: Sun, 6 Oct 2019 16:27:23 -0400 Subject: [PATCH] Resolve @svgr/webpack relative to next-svgr Previously, webpack would attempt to resolve @svgr/webpack relative to the Next.js project, which would result in an error like this using strict package managers like pnpm / Yarn PnP: Module not found: Can't resolve '@svgr/webpack' in '/path/to/project' Using `require.resolve()` fixes this. --- src/withSvg.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/withSvg.js b/src/withSvg.js index b715a32..5ea7c8d 100644 --- a/src/withSvg.js +++ b/src/withSvg.js @@ -3,7 +3,7 @@ const withSvg = (nextConfig = {}, nextComposePlugins = {}) => { webpack(config, options) { config.module.rules.push({ test: /\.svg$/, - use: ["@svgr/webpack"] + use: [require.resolve("@svgr/webpack")] }); if (typeof nextConfig.webpack === "function") {