https://github.com/gitim/react-app-rewire-svgr
https://github.com/gitim/react-app-rewire-svgr
create-react-app react react-app-rewired svgr webpack
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/gitim/react-app-rewire-svgr
- Owner: gitim
- Created: 2018-01-11T15:03:35.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-12-07T19:02:26.000Z (over 2 years ago)
- Last Synced: 2025-03-18T12:59:57.529Z (2 months ago)
- Topics: create-react-app, react, react-app-rewired, svgr, webpack
- Language: JavaScript
- Size: 198 KB
- Stars: 7
- Watchers: 1
- Forks: 3
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# react-app-rewire-svgr
Add [SVGR](https://github.com/smooth-code/svgr) loader to your [create-react-app](https://github.com/facebookincubator/create-react-app) via [react-app-rewired](https://github.com/timarney/react-app-rewired).
## Installation
```
yarn add --dev react-app-rewire-svgr
```OR
```
npm install --save-dev react-app-rewire-svgr
```## Usage
In your react-app-rewired configuration:
```js
/* config-overrides.js */const rewireSVGR = require('react-app-rewire-svgr');
module.exports = function override(config, env) {
// ...
config = rewireSVGR(config, env);
// ...
return config;
}
```
In your React application:
```js
import starUrl, { ReactComponent as Star } from './star.svg'const App = () => (
)
```Also you can pass options to svgr webpack loader via third parameter
```js
/* config-overrides.js */const rewireSVGR = require('react-app-rewire-svgr');
module.exports = function override(config, env) {
// ...
config = rewireSVGR(config, env, { svgo: false });
// ...
return config;
}
```