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)
- Host: GitHub
- URL: https://github.com/xpl/parcel-plugin-svg-react
- Owner: xpl
- License: mit
- Created: 2020-05-02T20:00:56.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-06T04:50:27.000Z (over 3 years ago)
- Last Synced: 2025-03-27T02:39:24.127Z (over 1 year ago)
- Language: JavaScript
- Size: 1.31 MB
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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);
}
```