Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
@svgr/cli is a command-line tool that allows you to transform SVG files into React components. It provides a simple and efficient way to integrate SVGs into your React applications, offering various customization options and optimizations.
Convert SVG to React Component
This command converts an SVG file into a React component and saves it in the specified output directory. It simplifies the process of using SVGs in React applications by automating the conversion.
npx @svgr/cli path/to/icon.svg --out-dir src/components
Optimize SVG
This command not only converts the SVG to a React component but also optimizes the SVG using SVGO (SVG Optimizer) with a custom configuration file. This helps in reducing the file size and improving performance.
npx @svgr/cli path/to/icon.svg --out-dir src/components --svgo-config ./svgo.config.js
Custom Template
This command allows you to use a custom template for generating the React component. You can define your own template to control the structure and styling of the generated component.
npx @svgr/cli path/to/icon.svg --out-dir src/components --template ./template.js
TypeScript Support
This command generates TypeScript React components from SVG files. It is useful for TypeScript projects, ensuring type safety and better integration with TypeScript tooling.
npx @svgr/cli path/to/icon.svg --out-dir src/components --typescript
react-svg-loader is a Webpack loader that transforms SVGs into React components. Unlike @svgr/cli, it is used within a Webpack build process, making it suitable for projects that already use Webpack for bundling.
svg-react-loader is another Webpack loader for converting SVGs to React components. It offers similar functionality to @svgr/cli but is integrated into the Webpack build pipeline, providing a seamless development experience for Webpack users.
react-inlinesvg is a React component that loads and injects SVGs inline. Unlike @svgr/cli, it does not convert SVGs to React components but allows you to use SVGs directly in your React components, providing a different approach to SVG integration.
Command Line Interface for SVGR.
npm install @svgr/cli --save-dev
Usage: svgr [options] <file|directory>
Options:
-V, --version output the version number
--config-file <file> specify the path of the svgr config
--no-runtime-config disable runtime config (".svgrrc", ".svgo.yml", ".prettierrc")
-d, --out-dir <dirname> output files into a directory
--ignore-existing ignore existing files when used with --out-dir
--ext <ext> specify a custom file extension (default: "js")
--filename-case <case> specify filename case ("pascal", "kebab", "camel", "snake") (default: "pascal")
--icon use "1em" as width and height
--native add react-native support with react-native-svg
--memo add React.memo into the result component
--ref forward ref to SVG root element
--no-dimensions remove width and height from root SVG tag
--expand-props [position] disable props expanding ("start", "end", "none") (default: "end")
--svg-props <property=value> add props to the svg element
--replace-attr-values <old=new> replace an attribute value
--template <file> specify a custom template to use
--index-template <file> specify a custom index.js template to use
--no-index disable index file generation
--title-prop create a title element linked with props
--desc-prop create a desc element linked with props
--prettier-config <fileOrJson> Prettier config
--no-prettier disable Prettier
--svgo-config <fileOrJson> SVGO config
--no-svgo disable SVGO
--silent suppress output
--stdin force reading input from stdin
--stdin-filepath path to the file to pretend that stdin comesfrom
-h, --help output usage information
Examples:
svgr --replace-attr-values "#fff=currentColor" icon.svg
MIT
FAQs
SVGR command line.
The npm package @svgr/cli receives a total of 288,433 weekly downloads. As such, @svgr/cli popularity was classified as popular.
We found that @svgr/cli demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.