Add SVGR loader to create-react-app using react-app-rewired
npm install react-app-rewire-svgrAdd SVGR loader to your create-react-app via react-app-rewired.
```
yarn add --dev react-app-rewire-svgr
OR
``
npm install --save-dev react-app-rewire-svgr
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;
}
``