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

SVGO - Are plugins actually working? #53

Closed
irv-armenta-g opened this issue Apr 18, 2024 · 1 comment · Fixed by #54
Closed

SVGO - Are plugins actually working? #53

irv-armenta-g opened this issue Apr 18, 2024 · 1 comment · Fixed by #54

Comments

@irv-armenta-g
Copy link

Hello, I am wondering if I'm doing something incorrect

I'm using the cli with this command:

$ svg-symbol-sprite  -i ./src/components/Icon/icons-library -o ./public/svg-symbols.svg --config svgo.config.js

where config is a custom file I have created in the root of the project (same level as package.json)

this is my config file:

const myPlugin = {
  name: 'makeEverythingPink',
  description: 'Change all fill attribute values to pink.',
  fn: () => {
    return {
      element: {
        enter: (node, parentNode) => {
          if (node.attributes.fill === null) {
            return;
          }

          node.attributes.fill = 'pink';
        }
      }
    };
  }
};

module.exports = {
  plugins: [
    'cleanupAttrs',
    'removeDoctype',
    'removeXMLProcInst',
    'removeComments',
    'removeMetadata',
    'removeUselessDefs',
    'removeEditorsNSData',
    'removeEmptyAttrs',
    'removeEmptyText',
    'removeEmptyContainers',
    'cleanupEnableBackground',
    'convertStyleToAttrs',
    'removeUselessStrokeAndFill',
    'removeDimensions',
    'cleanupIds',
    {
      name: 'removeViewBox',
      enabled: false
    },
    {
      name: 'prefixIds',
      params: {
        prefix: {
          toString() {
            this.counter = this.counter || 0;

            return `svgo-viewbox-id-${this.counter++}`;
          }
        }
      }
    },
    myPlugin
  ]
};

myPlugin is an example located in svgo website, but it seems is not really working at all, I keep getting the same fill value as is declared in the original <svg /> file.

I have checked the console log for both enter: and exit: of the function, it seems to actually change the fill: 'pink' like this, but the generated svg symbols still have the original fill.

Am I doing something wrong? I am not completely sure if this is an svgo issue or a svg-symbol-sprite issue though.

@scriptex scriptex linked a pull request Apr 22, 2024 that will close this issue
@scriptex
Copy link
Owner

Thanks for reporting this, @irv-armenta-g, it has been fixed in the latest version.
You can download it from Github or NPM

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

Successfully merging a pull request may close this issue.

2 participants