A simple Node.js terminal app for bulk converting SVG files to TypeScript React (TSX) files using SVGR.
npm install -g svg-to-react-tsx
svg-to-react-tsx <Folder path of SVGs> [TSX Output Folder] [--lazy] [--suffix="Suffix"] []
Use lazy importing for your index.ts.
Prefix output filename and component prefix (default is "Icon").
Suffix output filename and component suffix.
To convert all the SVG files in the folder svgs and save the resulting TSX files to the folder components, use the following command:
svg-to-react-tsx svgs components
To convert all the SVG files in the folder svgs, save the resulting TSX files to the same folder, and give the components a suffix of "SVG", use the following command:
svg-to-react-tsx svgs --suffix="SVG" --lazy
This script requires Node.js and SVGR to be installed on your system. Please refer to the official documentation for installation instructions.
Feel free to contribute to this project by opening a pull request or an issue.