Socket
Socket
Sign inDemoInstall

parcel-plugin-svg-react

Package Overview
Dependencies
300
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    parcel-plugin-svg-react

Import SVG as React components (Parcel plugin)


Version published
Weekly downloads
159
decreased by-43.01%
Maintainers
1
Install size
18.1 MB
Created
Weekly downloads
 

Readme

Source

parcel-plugin-svg-react

Parcel plugin for SVGR. Forked from @svgr/parcel-plugin-svgr.

npm install parcel-plugin-svg-react

The Differences

  • .svgr extension for React imports
  • .svg extension for path imports
  • Allows CSS imports

React Imports

Allows to import SVG files as React components. The extension should be .svgr, not .svg!

import Star from './star.svgr'

const App = () => (
  <div>
    <Star />
  </div>
)

Usual Behavior

Allows to import .svg files as paths (the usual Parcel behavior):

import star from './star.svg'

const Star = () => (
  <div style={{ backgroundImage: `url(${ star })` }}></div>
)

CSS Imports

This works as well:

div {
  background-image: url(./star.svg);
}

Keywords

FAQs

Last updated on 02 May 2020

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc