esbuild-plugin-svgr
A plugin for esbuild that adds support for *.svg
file imports as React components. The plugin is built on top of SVGR.
Basic Usage
- Install the plugin in your project:
npm install --save-dev esbuild-plugin-svgr
yarn add --dev esbuild-plugin-svgr
- Add this plugin to your esbuild build script:
import esbuild from 'esbuild'
import svgr from 'esbuild-plugin-svgr'
await esbuild.build({
plugins: [
svgr(),
],
})
- Import your
*.svg
file from JavaScript:
import Icon from './icon.svg';
function App() {
return (
<div>
<Icon />
</div>
);
}
- Pass in optional supported configuration options:
esbuild.build({
plugins: [
svgr({ ref: true }),
],
});
License
This project is licensed under the MIT License - see the LICENSE.md file for details.
Acknowledgements
SVGR