Tiny module for transforming SVG to valid JSX
yarn add @balajmarius/svg-to-jsx --dev
yarn test
const fs = require('fs')
const path = require('path')
const transform = require('@balajmarius/svg-to-jsx')
const filepath = path.resolve(__dirname, 'test.svg')
fs.readFile(filepath, 'utf8', (error, data) => {
if (error) throw new Error('π Something went wrong')
return transform(data)
.then(transformedSVG => console.log(transformedSVG))
.catch(error => console.log(error))
})
- Convert attributes to valid JSX attributes
- Convert CSS to Javascript
- Convert CSS (fill, display, ..) to attributes
- Remove useless attributes
- Single/double quotes option
- Format option
- React-native