Skip to content

spacedriveapp/vite-plugin-svgr

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vite-plugin-svgr

npm

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

Usage

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

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

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

About

Vite plugin to transform SVGs into React components

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 64.1%
  • TypeScript 35.9%