1.1.0 • Published 2 years ago

@iseei/vite-plugin-svgr v1.1.0

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

vite-plugin-svgr

npm

Vite plugin to transform SVGs into React components. Uses svgr under the hood.

Usage

// vite.config.js
import svgrPlugin from '@iseei/vite-plugin-svgr'

export default {
  // ...
  plugins: [
    svgrPlugin({
      svgrOptions: {
        icon: true,
        // ...svgr options (https://react-svgr.com/docs/options/)
      },
      defaultExportComponent: true,
    }),
  ],
}

Then SVG files can be imported as React components, just like create-react-app does:

import { ReactComponent as Logo } from './logo.svg'

If you are using TypeScript, vite-plugin-svgr/client can be added to tsconfig.json:

{
  // ...
  "compilerOptions": {
    // ...
    "types": ["vite-plugin-svgr/client"]
  }
}

License

MIT