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/core.
Basic Usage
- Install the plugin in your project:
npm install --save-dev esbuild-plugin-svgr
yarn add --dev esbuild-plugin-svg
- Add this plugin to your esbuild build script:
const svgrPlugin = require('esbuild-plugin-svgr')
esbuild.build({
plugins: [
svgrPlugin(),
],
})
- Import your
*.svg
file from JavaScript:
import Icon from './icon.svg';
const App = () => (
<div>
<Icon />
</div>
);
- Pass in optional supported configuration options:
esbuild.build({
plugins: [
svgrPlugin({ ref: true }),
],
})
Author
Kazi Jawad
License
This project is licensed under the MIT License - see the LICENSE.md file for details
Acknowledgements
@svgr/core