Skip to content

A plugin for esbuild that enables importing *.svg files as React components.

License

Notifications You must be signed in to change notification settings

crcls/esbuild-plugin-svgr

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

  1. Install the plugin in your project:
npm install --save-dev esbuild-plugin-svgr
# or use yarn
yarn add --dev esbuild-plugin-svgr
  1. Add this plugin to your esbuild build script:
const svgrPlugin = require('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

Kazi Jawad

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

Acknowledgements

SVGR

About

A plugin for esbuild that enables importing *.svg files as React components.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%