@sage-bionetworks/esbuild-plugin-svgr
v0.0.4
Published
A plugin for esbuild that enables importing *.svg files as React components.
Downloads
10
Keywords
Readme
esbuild-plugin-svgr
A plugin for esbuild that adds support for *.svg
file imports as React components. This is a fork of kazijawad/esbuild-plugin-svgr and is built on top of SVGR.
Basic Usage
- Install the plugin in your project:
npm install --save-dev @sage-bionetworks/esbuild-plugin-svgr
# or use yarn
yarn add --dev @sage-bionetworks/esbuild-plugin-svgr
- Add this plugin to your esbuild build script:
const svgrPlugin = require('@sage-bionetworks/esbuild-plugin-svgr');
esbuild.build({
plugins: [
svgrPlugin(),
],
});
- 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: [
svgrPlugin({ ref: true }),
],
});
Author
This fork is maintained by Sage Bionetworks. Originally by Kazi Jawad.
License
This project is licensed under the MIT License - see the LICENSE.md file for details.