Load svg files as preact components.
npm i --save-dev preact-svg-loader
// or
yarn add --dev preact-svg-loader
Add the loader to your webpack config.
rules: [
{
test: /\.svg$/,
use: ['preact-svg-loader'],
}
]
In your code, simply require the svg as if it were a component.
import Logo from './logo.svg';
() => <Logo />