From 30339bd9a306e07a6b5f3fbde53dc4649c12fc6e Mon Sep 17 00:00:00 2001 From: Kerry Date: Fri, 4 Mar 2022 13:57:26 +0100 Subject: [PATCH] fix webpack handling for svg imports (#21311) --- webpack.config.js | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/webpack.config.js b/webpack.config.js index e9d68480b0..fe72386a31 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -456,6 +456,7 @@ module.exports = (env, argv) => { }, { test: /\.svg$/, + issuer: /\.(js|ts|jsx|tsx|html)$/, use: [ { loader: '@svgr/webpack', @@ -478,10 +479,28 @@ module.exports = (env, argv) => { outputPath: getAssetOutputPath, publicPath: function (url, resourcePath) { const outputPath = getAssetOutputPath(url, resourcePath); - return toPublicPath(path.join("../..", outputPath)); + return toPublicPath(outputPath); }, }, }, + { + loader: 'file-loader', + options: { + esModule: false, + name: '[name].[hash:7].[ext]', + outputPath: getAssetOutputPath, + publicPath: function (url, resourcePath) { + const outputPath = getAssetOutputPath(url, resourcePath); + return toPublicPath(outputPath); + }, + }, + }, + ] + }, + { + test: /\.svg$/, + issuer: /\.(scss|css)$/, + use: [ { loader: 'file-loader', options: {