Skip to content

Commit c221d69

Browse files
lazyd3vgitim
authored andcommitted
Add possibility to pass options to svgr loader (#1)
* Add possibility to pass options to svgr loader * Upd readme
1 parent 70c11ed commit c221d69

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,17 @@ const App = () => (
3838
</div>
3939
)
4040
```
41+
42+
Also you can pass options to svgr webpack loader via third parameter
43+
```js
44+
/* config-overrides.js */
45+
46+
const rewireSVGR = require('react-app-rewire-svgr');
47+
48+
module.exports = function override(config, env) {
49+
// ...
50+
config = rewireSVGR(config, env, { svgo: false });
51+
// ...
52+
return config;
53+
}
54+
```

index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const { getBabelLoader } = require(`react-app-rewired`)
22

3-
function rewireSVGR(config) {
3+
function rewireSVGR(config, env, svgrLoaderOptions) {
44
const babelLoader = getBabelLoader(config.module.rules)
55
const svgReactLoader = {
66
test: /\.svg$/,
@@ -9,7 +9,10 @@ function rewireSVGR(config) {
99
loader : babelLoader.loader,
1010
options: babelLoader.options,
1111
},
12-
{ loader: require.resolve(`svgr/webpack`) },
12+
{
13+
loader: require.resolve(`svgr/webpack`),
14+
options: svgrLoaderOptions
15+
},
1316
],
1417
}
1518

0 commit comments

Comments
 (0)