* fix(misc): avoid issues with refs in SVGs The previous "import friendly" syntax was actually disabling refs in SVGs parsed by svgr. I found 3 possible solutions: 1. Removing "![path]" 2. Separating "+ref![path]" with another comma: "+ref,![path]" 3. Rewriting the loader entry in the style of the other loader entries I chose the last one for added clarity within the file. * fix(core): fix compilation errors
61 lines
1.4 KiB
TypeScript
61 lines
1.4 KiB
TypeScript
import { Configuration } from 'webpack';
|
|
|
|
// Add React-specific configuration
|
|
function getWebpackConfig(config: Configuration) {
|
|
config.module.rules.push(
|
|
{
|
|
test: /\.(png|jpe?g|gif|webp)$/,
|
|
loader: require.resolve('url-loader'),
|
|
options: {
|
|
limit: 10000, // 10kB
|
|
name: '[name].[hash:7].[ext]',
|
|
},
|
|
},
|
|
{
|
|
test: /\.svg$/,
|
|
oneOf: [
|
|
// If coming from JS/TS file, then transform into React component using SVGR.
|
|
{
|
|
issuer: {
|
|
test: /\.[jt]sx?$/,
|
|
},
|
|
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,
|
|
},
|
|
},
|
|
],
|
|
},
|
|
// Fallback to plain URL loader.
|
|
{
|
|
use: [
|
|
{
|
|
loader: require.resolve('url-loader'),
|
|
options: {
|
|
limit: 10000, // 10kB
|
|
name: '[name].[hash:7].[ext]',
|
|
},
|
|
},
|
|
],
|
|
},
|
|
],
|
|
}
|
|
);
|
|
|
|
return config;
|
|
}
|
|
|
|
module.exports = getWebpackConfig;
|