Skip to content

Commit

Permalink
Merge pull request #4 from rambler-digital-solutions/svgr-supports-op…
Browse files Browse the repository at this point in the history
…tions

svgr-supports-options
  • Loading branch information
andrepolischuk committed Jun 13, 2024
2 parents 1a12e7e + 2c3e3c2 commit f073c4c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
20 changes: 20 additions & 0 deletions packages/svgr/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,23 @@ module.exports = {
}
}
```

It's also possible to provide args from svgr plugin

```js
const SvgrPlugin = require('@rambler-tech/razzle-svgr')

module.exports = {
plugins: [
SvgrPlugin({
native: true,
})
],
modifyWebpackConfig({webpackConfig}) {
// ...
return webpackConfig
}
}
```

[Full list of options are avaible here](https://react-svgr.com/docs/options/)
9 changes: 7 additions & 2 deletions packages/svgr/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
module.exports = () => ({
module.exports = (options = {}) => ({
modifyWebpackConfig({webpackConfig}) {
webpackConfig.module.rules[1].exclude.push(/\.svg$/)

webpackConfig.module.rules.push({
test: /\.svg$/,
use: ['@svgr/webpack']
use: [
{
loader: '@svgr/webpack',
options: {...options}
}
]
})

return webpackConfig
Expand Down

0 comments on commit f073c4c

Please sign in to comment.