Security News
vlt Debuts New JavaScript Package Manager and Serverless Registry at NodeConf EU
vlt introduced its new package manager and a serverless registry this week, innovating in a space where npm has stagnated.
@svgr/babel-preset
Advanced tools
The @svgr/babel-preset package is a Babel preset for transforming SVG icons into React components. This allows developers to import SVG files directly as React components in their projects, facilitating easier manipulation and integration of SVGs within React applications.
SVG to React Component Transformation
This feature allows SVG files to be imported directly as React components. This is useful for developers who want to use SVGs as components without manually converting them. The code shows how an SVG file can be imported and used as a React component.
import ReactComponent from './icon.svg';
Customizable SVG Transformation
Developers can customize how SVGs are transformed into React components. Options such as disabling SVGO optimization or adding a title prop to the SVG can be configured. The code sample demonstrates how to customize the Babel preset configuration for SVG transformation.
{
"presets": [
"@svgr/babel-preset",
{
"icon": true,
"svgo": false,
"titleProp": true
}
]
}
react-svg-loader is similar to @svgr/babel-preset as it also allows importing SVGs as React components. However, it is implemented as a webpack loader rather than a Babel preset, which might suit different project setups.
This plugin provides similar functionality by allowing SVGs to be imported as React components. It differs in that it is a Babel plugin, offering more integration with Babel's ecosystem and possibly differing in configuration and performance characteristics.
npm install --save-dev @svgr/babel-preset
.babelrc
{
"presets": [["@svgr/babel-preset", { "svgProps": { "width": 200 } }]]
}
MIT
FAQs
SVGR preset that apply transformations from config
The npm package @svgr/babel-preset receives a total of 4,710,175 weekly downloads. As such, @svgr/babel-preset popularity was classified as popular.
We found that @svgr/babel-preset 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
vlt introduced its new package manager and a serverless registry this week, innovating in a space where npm has stagnated.
Security News
Research
The Socket Research Team uncovered a malicious Python package typosquatting the popular 'fabric' SSH library, silently exfiltrating AWS credentials from unsuspecting developers.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.