Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flexible SVGO settings for different folders #78

Open
lancedikson opened this issue Jun 16, 2018 · 6 comments
Open

Flexible SVGO settings for different folders #78

lancedikson opened this issue Jun 16, 2018 · 6 comments

Comments

@lancedikson
Copy link

Hi, @ivanvotti

Great addon you have here 👍 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
Copy link
Collaborator

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
Copy link
Author

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
Copy link
Collaborator

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
Copy link
Author

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

@pusle
Copy link

pusle commented Aug 20, 2018

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants