Skip to content

Commit

Permalink
Fix wrong import svg from styles files in react
Browse files Browse the repository at this point in the history
  • Loading branch information
nglazov committed Oct 9, 2022
1 parent 080a896 commit 53ca2dd
Showing 1 changed file with 18 additions and 31 deletions.
49 changes: 18 additions & 31 deletions packages/react/plugins/webpack.ts
Expand Up @@ -5,42 +5,29 @@ 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('url-loader'),
options: {
limit: 10000, // 10kB
name: '[name].[hash:7].[ext]',
esModule: false,
},
},
],
}, {
test: /\.svg$/,
issuer: /\.(css|scss|less|sass|styl|stylus)?$/,
type: 'assets/resource'
});

if (config.mode === 'development' && config['devServer']?.hot) {
Expand Down

0 comments on commit 53ca2dd

Please sign in to comment.