fix(react): add fallback for SVG imports coming from non-TS/JS modules (#2351)

This commit is contained in:
Jack Hsu 2020-01-21 10:06:30 -05:00 committed by GitHub
parent 1132d9ec57
commit 20885513ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -18,17 +18,34 @@ function getWebpackConfig(config: Configuration) {
}, },
{ {
test: /\.svg$/, test: /\.svg$/,
issuer: { oneOf: [
test: /\.[jt]sx?$/ // If coming from JS/TS file, then transform into React component using SVGR.
},
use: [
'@svgr/webpack?-svgo,+titleProp,+ref![path]',
{ {
loader: 'url-loader', issuer: {
options: { test: /\.[jt]sx?$/
limit: 10000, // 10kB },
name: '[name].[hash:7].[ext]' use: [
} '@svgr/webpack?-svgo,+titleProp,+ref![path]',
{
loader: 'url-loader',
options: {
limit: 10000, // 10kB
name: '[name].[hash:7].[ext]'
}
}
]
},
// Fallback to plain URL loader.
{
use: [
{
loader: 'url-loader',
options: {
limit: 10000, // 10kB
name: '[name].[hash:7].[ext]'
}
}
]
} }
] ]
} }