evoactivity / ember-svg-jar

🍯 Best way to use SVG images in Ember apps
https://svgjar.web.app
251 stars 73 forks source link

Flexible SVGO settings for different folders #78

Open lancedikson opened 6 years ago

lancedikson commented 6 years ago

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 :)

voltidev commented 6 years ago

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.

lancedikson commented 6 years ago

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?

voltidev commented 6 years ago

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.

lancedikson commented 6 years ago

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

pusle commented 6 years ago

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.

simonihmig commented 5 years ago

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).