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.
gatsby-plugin-svgr
Advanced tools
SVGR plugin for Gatsby v2.0+. Still rocking Gatsby v1? See the v1 branch instead.
As of v2.0, SVGR is declared as a peer dependency. You will need to add gatsby-plugin-svgr
as well as @svgr/webpack
to your dependencies.
$ npm install @svgr/webpack gatsby-plugin-svgr
or
$ yarn add @svgr/webpack gatsby-plugin-svgr
gatsby-config.js
module.exports = {
plugins: [
'gatsby-plugin-svgr',
],
}
Note: If you need to configure SVGO, we recommended this approach instead of the below. Documentation update to follow.
Any options you configure gatsby-plugin-svgr
with will be passed on to svgr
with the exception of include
and exclude
(see below). You can see a full list of SVGR options here (you want the API override version). SVGR uses SVGO to optimize SVGs; you can configure SVGO using svgoConfig
; see SVGO for a full list of configuration options.
module.exports = {
plugins: [
{
resolve: 'gatsby-plugin-svgr',
options: {
prettier: true, // use prettier to format JS code output (default)
svgo: true, // use svgo to optimize SVGs (default)
svgoConfig: {
plugins: [
{ removeViewBox: true }, // remove viewBox when possible (default)
{ cleanupIDs: true }, // remove unused IDs and minify remaining IDs (default)
],
},
},
},
],
}
Note: SVGO does not produce unique IDs when using the cleanupIDs
option; if you're using SVGs that rely on IDs (e.g. to target template elements with use
) and include multiple SVGs on the same page you may wish to disable the cleanupIDs
option to prevent conflicts. Alternately you can disable svgo
altogether and perform any optimization either manually or through another build process.
By default, SVGR is only used to load resources when loaded via JS (i.e. your stylesheets will fallback to the default loader). If you only want to apply SVGR to some resources, or you want to exclude some resources, you can pass include
or exclude
as options. These are passed directly to the SVGR loader as Conditions.
{
resolve: 'gatsby-plugin-svgr',
options: {
exclude: /some_special_folder/,
},
}
import starUrl, { ReactComponent as Star } from './star.svg'
const App = () => (
<div>
<img src={starUrl} alt="star" />
<Star />
</div>
)
FAQs
SVGR plugin for Gatsby
The npm package gatsby-plugin-svgr receives a total of 9,237 weekly downloads. As such, gatsby-plugin-svgr popularity was classified as popular.
We found that gatsby-plugin-svgr demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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.