From 154c412be86e02a28a8feec1b34a961553652c4c Mon Sep 17 00:00:00 2001 From: Andrey Varenov Date: Thu, 13 Jun 2024 18:52:07 +0300 Subject: [PATCH] svgr-supports-options --- packages/svgr/README.md | 20 ++++++++++++++++++++ packages/svgr/index.js | 9 +++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/packages/svgr/README.md b/packages/svgr/README.md index 1cf5eb9..1936cd9 100644 --- a/packages/svgr/README.md +++ b/packages/svgr/README.md @@ -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/) \ No newline at end of file diff --git a/packages/svgr/index.js b/packages/svgr/index.js index da90d5e..f03b9a2 100644 --- a/packages/svgr/index.js +++ b/packages/svgr/index.js @@ -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, + }, + ], }) return webpackConfig