ember-svg-jar icon indicating copy to clipboard operation
ember-svg-jar copied to clipboard

Flexible SVGO settings for different folders

Open lancedikson opened this issue 6 years ago • 6 comments

Hi, @ivanvotti

Great addon you have here :+1: I have a feature request. I ran into a requirement to have separated SVGO configs for different folders, but then join them into one single file with symbols. Here is an example:

We have two types of icons: monochrome and colored. So, we put them to app/assets/icons/mono and app/assets/icons/colored respectively. SVG files are stored as they out using Sketch exporting tool. We don’t want to preprocess them with SVGO beforehand and put to the project, since configuration may differ from time to time and for different people, if they use SVGO as a Sketch plugin. That’s why we would rather save sources in app/assets/icons/ foulders. So, what I’m offering here is to have such a flexible configuration available:

svgJar: {
  strategy: 'symbol',

  symbol: {
    files: [
      {
        sourceDirs: ['app/assets/icons/mono'],
        svgoConfig: {
          plugins: [{
            removeAttrs: {
              attrs: '(stroke|fill)'
            }
          }]
        }
      },
      {
        sourceDirs: ['app/assets/icons/colored'],
        svgoConfig: {}
      }
    ],
    prefix: 'icon-'
  }
}

Do you think this is something that could have place in the addon and could be developed soon? I could take care of this if only I was sure that these changes would be something that is wanted to be merged and correspond with your view on this :)

lancedikson avatar Jun 16 '18 11:06 lancedikson

Hi. It’s related to #41 and I like the idea. Just need to think how we can keep the configuration as simple as possible.

voltidev avatar Jun 18 '18 09:06 voltidev

Well, I think everything should be same as it is now, we just could add one more level of configuration:

 global
   ↓
strategy
   ↓
directory

And on each level we can redefine something, or add level-specific configuration. On the new directory level it should be possible to redefine all those options that we can define for the whole strategy. What do you think?

lancedikson avatar Jun 20 '18 12:06 lancedikson

I’ll try to find time this week to make it possible to use objects in the sourceDirs array (#41), so that you can define directory specific optimization and prefix.

voltidev avatar Jun 28 '18 08:06 voltidev

Cool! Looking forward to it. Ping me if you need any help from a collaborator ;)

lancedikson avatar Jun 28 '18 09:06 lancedikson

Hi and thanks for an awesome addon. I just wanted to ask if there was an update to this feature request? I suddenly found myself in need of this functionality.

pusle avatar Aug 20 '18 17:08 pusle

Yes, please!

Run into a similar need, to convert monochrome icons to use currentColor (awesome feature btw, for dynamic CSS-based coloring), but leave colored ones untouched (regarding colors).

simonihmig avatar Nov 15 '18 14:11 simonihmig