Answer the question
In order to leave comments, you need to log in
How to exclude webpack loader based on resource import form?
Good evening.
There is an application built via create-react-app. As you know, CRA offers a way to import SVGs as components.
import { ReactComponent as LogoIcon } from '@/assets/logo.svg';
plugins: [
[
require.resolve('babel-plugin-named-asset-import'),
{
loaderMap: {
svg: {
ReactComponent:
'@svgr/webpack?-svgo,+titleProp,+ref![path]',
},
},
},
],
],
{
test: /\.svg$/,
use: [
{
loader: 'svg-sprite-loader',
options: {
symbolId: 'icon-[name]'
}
}
]
},
import icon from 'icon.svg'; // svg-sprite-loader
import { ReactComponent as icon } from './icon.svg'; // cra-loader
Answer the question
In order to leave comments, you need to log in
It is possible to write a function that will return svg paths as jsx. You don't need webpack for this.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question