Mohammad Asif cf937194cb Removed un-waned things 1. | 5 månader sedan | |
---|---|---|
.. | ||
dist | 5 månader sedan | |
node_modules | 5 månader sedan | |
LICENSE | 5 månader sedan | |
README.md | 5 månader sedan | |
package.json | 5 månader sedan |
Node API of SVGR.
npm install @svgr/core
import { transform } from '@svgr/core'
const svgCode = `
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<rect x="10" y="10" height="100" width="100"
style="stroke:#ff0000; fill: #0000ff"/>
</svg>
`
transform(svgCode, { icon: true }, { componentName: 'MyComponent' }).then(
(jsCode) => {
console.log(jsCode)
},
)
Use svgr.sync(code, config, state)
if you would like to use sync version.
By default @svgr/core
doesn't include svgo
and prettier
plugins, if you want them, you have to install them and include them in config.
svgr(svgCode, {
plugins: ['@svgr/plugin-svgo', '@svgr/plugin-jsx', '@svgr/plugin-prettier'],
}).then((jsCode) => {
console.log(jsCode)
})
MIT