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 241a0fd
Show file tree
Hide file tree
Showing 2 changed files with 13 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
1 change: 1 addition & 0 deletions scripts/depcheck/missing.ts
Expand Up @@ -96,6 +96,7 @@ const IGNORE_MATCHES_IN_PACKAGE = {
'babel-plugin-emotion',
'babel-plugin-styled-components',
'css-loader',
'file-loader',
'less-loader',
'react-refresh',
'rollup',
Expand Down

0 comments on commit 241a0fd

Please sign in to comment.