Svgr: @svgr/webpack — passing options does nothing

Created on 24 Sep 2019  ·  4Comments  ·  Source: gregberge/svgr

🐛 Bug Report

Here is my rule:

  const inlineSvgRule = {
    test: /\.inline.svg$/,
    use: [
      {
        loader: require.resolve('@svgr/webpack'),
        options: {
          svgoConfig: {
            removeViewBox: false,
            cleanupIDs: {
              prefix: {
                toString() {
                  this.counter = this.counter || 0;
                  return `id-${this.counter++}`;
                },
              },
            },
          },
        },
      },
    ],
    issuer: {
      test: /\.(js|jsx|ts|tsx)$/,
    },
  };

Passing options literally does nothing

Run npx envinfo --system --binaries --npmPackages @svgr/core,@svgr/cli,@svgr/webpack,@svgr/rollup --markdown --clipboard

Paste the results here:

## System:
 - OS: macOS 10.14.5
 - CPU: (4) x64 Intel(R) Core(TM) i5-5257U CPU @ 2.70GHz
 - Memory: 73.98 MB / 8.00 GB
 - Shell: 5.3 - /bin/zsh
## Binaries:
 - Node: 12.10.0 - /usr/local/bin/node
 - Yarn: 1.17.3 - /usr/local/bin/yarn
 - npm: 6.11.3 - /usr/local/bin/npm
## npmPackages:
 - @svgr/webpack: ^4.3.3 => 4.3.3
bug 🐛

Most helpful comment

@SilencerWeb I've found a way to fix it.

You should pass svgoConfig as below:

options: {
  svgoConfig: {
    plugins: [{
      removeViewBox: false,
    }]
  }
} 

All 4 comments

You should use svgo instead svgoConfig.

  1. Doesn't work either :c
  2. Docs say that svgo is boolean and svgoConfig is object
    image

Oh sorry you are right. So it is actually a bug.

@SilencerWeb I've found a way to fix it.

You should pass svgoConfig as below:

options: {
  svgoConfig: {
    plugins: [{
      removeViewBox: false,
    }]
  }
} 
Was this page helpful?
0 / 5 - 0 ratings