Skip to content

Commit

Permalink
fix(react) fix SVG imports from CSS modules
Browse files Browse the repository at this point in the history
  • Loading branch information
nglazov authored and Jack Hsu committed Dec 19, 2022
1 parent 915dc25 commit 1d7af47
Showing 1 changed file with 12 additions and 31 deletions.
43 changes: 12 additions & 31 deletions packages/react/plugins/webpack.ts
Expand Up @@ -5,40 +5,21 @@ import ReactRefreshPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
export function getWebpackConfig(config: Configuration) {
config.module.rules.push({
test: /\.svg$/,
oneOf: [
// If coming from JS/TS or MDX file, then transform into React component using SVGR.
issuer: /\.(js|ts|md)x?$/,
use: [
{
issuer: /\.(js|ts|md)x?$/,
use: [
{
loader: require.resolve('@svgr/webpack'),
options: {
svgo: false,
titleProp: true,
ref: true,
},
},
{
loader: require.resolve('url-loader'),
options: {
limit: 10000, // 10kB
name: '[name].[hash:7].[ext]',
esModule: false,
},
},
],
loader: require.resolve('@svgr/webpack'),
options: {
svgo: false,
titleProp: true,
ref: true,
},
},
// Fallback to plain URL loader.
{
use: [
{
loader: require.resolve('url-loader'),
options: {
limit: 10000, // 10kB
name: '[name].[hash:7].[ext]',
},
},
],
loader: require.resolve('file-loader'),
options: {
name: '[name].[hash].[ext]',
},
},
],
});
Expand Down

0 comments on commit 1d7af47

Please sign in to comment.