@sage-bionetworks/esbuild-plugin-svgr
TypeScript icon, indicating that this package has built-in type declarations

0.0.4 • Public • Published

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

  1. 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
  1. Add this plugin to your esbuild build script:
const svgrPlugin = require('@sage-bionetworks/esbuild-plugin-svgr');

esbuild.build({
    plugins: [
        svgrPlugin(),
    ],
});
  1. Import your *.svg file from JavaScript:
import Icon from './icon.svg';

function App() {
    return (
        <div>
            <Icon />
        </div>
    );
}
  1. 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.

Acknowledgements

SVGR

Readme

Keywords

none

Package Sidebar

Install

npm i @sage-bionetworks/esbuild-plugin-svgr

Weekly Downloads

2

Version

0.0.4

License

MIT

Unpacked Size

3.83 kB

Total Files

5

Last publish

Collaborators

  • jay-hodgson
  • xschildwachter
  • agendel
  • nickgros
  • roccbot