An open API service indexing awesome lists of open source software.

https://github.com/xpl/parcel-plugin-svg-react

Import SVG as React components (Parcel plugin)
https://github.com/xpl/parcel-plugin-svg-react

Last synced: 9 months ago
JSON representation

Import SVG as React components (Parcel plugin)

Awesome Lists containing this project

README

          

# 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`!

```jsx
import Star from './star.svgr'

const App = () => (




)
```

## Usual Behavior

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

```jsx
import star from './star.svg'

const Star = () => (


)
```

## CSS Imports

This works as well:

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