<h1 align="center">SVGR RS</h1>
npm install @svgr-rs/coreSpeedy SVGR rewritten in Rust 🦀
If you are using SVGR RS from Rust, see rustdoc and for most uses.
SVGR RS provides an webpack loader to import SVG as React components.
``sh`
npm install --save-dev @svgr-rs/svgrs-pluginor use yarn
yarn add --dev @svgr-rs/core
webpack.config.js
`js`
{
test: /\.svg$/i,
issuer: /\.[jt]sx?$/,
resourceQuery: /react/,
use: [
{
loader: '@svgr-rs/svgrs-plugin/webpack',
options: {
exportType: 'named',
namedExport: 'ReactComponent',
},
},
],
}
SVGR RS provides an vite plugin to import SVG as React components.
`sh`
npm install --save-dev @svgr-rs/svgrs-pluginor use yarn
yarn add --dev @svgr-rs/core
vite.config.js
`js
import react from '@vitejs/plugin-react'
import { svgrs } from '@svgr-rs/svgrs-plugin/vite'
import { defineConfig } from 'vite'
export default defineConfig({
plugins: [
react(),
svgrs({
exportType: 'named',
namedExport: 'ReactComponent',
})
],
})
`
Use SVGR RS in Node.js to complex transformations or tools.
`sh`
npm install --save-dev @svgr-rs/coreor use yarn
yarn add --dev @svgr-rs/core
Import transform from @svgr-rs/core to transform a file. It takes three arguments:
* source: the SVG source code to transformoptions
* : the options used to transform the SVGstate
* : a state linked to the transformation
`js
import { transform } from '@svgr-rs/core'
const svgCode =
xmlns:xlink="http://www.w3.org/1999/xlink">
const jsCode = await transform(
svgCode,
{ icon: true },
{ componentName: 'MyComponent' },
)
``
Transform time without SVGO and Prettier in W3C SVG 1.1 TestSuite:
- [x] jsxRuntime
- [x] jsxRuntimeImport
- [x] icon
- [x] native
- [x] typescript
- [x] dimensions
- [x] expandProps
- [ ] prettier
- [ ] prettierConfig
- [ ] svgo (Speedy SVGO rewritten in Rust is working in progress)
- [ ] svgoConfig
- [x] ref
- [x] memo
- [x] replaceAttrValues
- [x] svgProps
- [x] titleProp
- [x] descProp