docz icon indicating copy to clipboard operation
docz copied to clipboard

Have the ability to set SVGR built-in configuration

Open danielbayerlein opened this issue 8 years ago • 10 comments

Question

How can I configure the SVGR built-in?

My current loader looks like this:

test: /\.svg$/,
use: {
  loader: '@svgr/webpack',
  options: {
    icon: true,
    replaceAttrValues: {
      '#1a171b': 'currentColor'
    }
  }
}

danielbayerlein avatar Oct 05 '18 06:10 danielbayerlein

You can use the modifyBundlerConfig

// doczrc.js
export default {
  modifyBundlerConfig: (config) => {
    /* custom loaders */
    config.module.rules.push({
        test: /\.svg$/,
        use: '@svgr/webpack',
    });
    return config
  }
}

lasimonne avatar Oct 10 '18 06:10 lasimonne

@lasimonne In your example you add the @svgr/webpack loader, but it is already integrated in the new version of docz. Let me know if I misunderstood something.

danielbayerlein avatar Oct 10 '18 08:10 danielbayerlein

@danielbayerlein I might have misunderstood you, are you talking about .svgrrc configuration?

lasimonne avatar Oct 10 '18 17:10 lasimonne

@lasimonne Thanks, I did not know the configuration file! But it looks like the configuration file is ignored. 😕

danielbayerlein avatar Oct 11 '18 06:10 danielbayerlein

https://github.com/smooth-code/svgr#configurations

danielbayerlein avatar Nov 05 '18 14:11 danielbayerlein

Hi @danielbayerlein, that's is something that we need to put on doczrc. I'll do that and put for the last release 🙏

pedronauck avatar Nov 05 '18 17:11 pedronauck

Hi @pedronauck, thank you! You can configure SVGR itself via .svgrrc, svgr.config.js or svgr key in the package.json file.

danielbayerlein avatar Nov 06 '18 06:11 danielbayerlein

oh, really? and this work actually with docz too @danielbayerlein ?

pedronauck avatar Nov 07 '18 12:11 pedronauck

@pedronauck Yes, the configuration file .svgrrc works fine.

danielbayerlein avatar Nov 07 '18 12:11 danielbayerlein

Cool! So, I'll let just this config instead of put a new property on doczrc, thanks to the tip dude 🙏

pedronauck avatar Nov 07 '18 13:11 pedronauck