0.0.4 • Published 2 years ago

@sage-bionetworks/esbuild-plugin-svgr v0.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

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