Spaces:
Sleeping
Sleeping
|
Download frontend/node_modules/@svgr/plugin-jsx/README.md from sepidnes/pythonic-rag-FastAPIReact: direct link, hf CLI and curl.
- Browser
- Download file 2.41 kB
-
https://huggingface.co/spaces/sepidnes/pythonic-rag-FastAPIReact/resolve/94e32638a275d46bc1ba62feac204fcaaf313da4/frontend/node_modules/%40svgr/plugin-jsx/README.md
- Command line
-
hf download hf://spaces/sepidnes/pythonic-rag-FastAPIReact@94e32638a275d46bc1ba62feac204fcaaf313da4/frontend/node_modules/@svgr/plugin-jsx/README.md
-
curl -L -o README.md https://huggingface.co/spaces/sepidnes/pythonic-rag-FastAPIReact/resolve/94e32638a275d46bc1ba62feac204fcaaf313da4/frontend/node_modules/%40svgr/plugin-jsx/README.md
2.41 kB
@svgr/plugin-jsx
Transforms SVG into JSX.
Install
npm install --save-dev @svgr/plugin-jsx
Usage
.svgrrc
{
"plugins": ["@svgr/plugin-jsx"]
}
How does it work?
@svgr/plugin-jsx consists in three phases:
- Parsing the SVG code using svg-parser
- Converting the HAST into a Babel AST
- Applying
@svgr/babel-presettransformations
Applying custom transformations
You can extend the Babel config applied in this plugin using jsx.babelConfig config path:
// .svgrrc.js
module.exports = {
jsx: {
babelConfig: {
plugins: [
// For an example, this plugin will remove "id" attribute from "svg" tag
[
'@svgr/babel-plugin-remove-jsx-attribute',
{
elements: ['svg'],
attributes: ['id'],
},
],
],
},
},
}
Several Babel plugins are available:
@svgr/babel-plugin-add-jsx-attribute@svgr/babel-plugin-remove-jsx-attribute@svgr/babel-plugin-remove-jsx-empty-expression@svgr/babel-plugin-replace-jsx-attribute-value@svgr/babel-plugin-svg-dynamic-title@svgr/babel-plugin-svg-em-dimensions@svgr/babel-plugin-transform-react-native-svg@svgr/babel-plugin-transform-svg-component
If you want to create your own, reading Babel Handbook is a good start!
License
MIT