unplugin-svgr2
v0.1.0
Published
unplugin to transform SVGs into React components. Uses [svgr](https://react-svgr.com/) under the hood.
Maintainers
Readme
unplugin-svgr2
unplugin to transform SVGs into React components. Uses svgr under the hood.
Install
npm i unplugin-svgr2// vite.config.ts
import react from '@vitejs/plugin-react'
import svgr from 'unplugin-svgr2/vite'
export default defineConfig({
plugins: [
react(),
svgr({ /* options */ }),
],
})Example: playground/
// rollup.config.js
import svgr from 'unplugin-svgr2/rollup'
export default {
plugins: [
svgr({ /* options */ }),
],
}// webpack.config.js
module.exports = {
/* ... */
plugins: [
require('unplugin-svgr2/webpack')({ /* options */ })
]
}// nuxt.config.js
export default defineNuxtConfig({
modules: [
['unplugin-svgr2/nuxt', { /* options */ }],
],
})This module works for both Nuxt 2 and Nuxt Vite
// vue.config.js
module.exports = {
configureWebpack: {
plugins: [
require('unplugin-svgr2/webpack')({ /* options */ }),
],
},
}// esbuild.config.js
import { build } from 'esbuild'
import svgr from 'unplugin-svgr2/esbuild'
build({
plugins: [svgr()],
})