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

Multiple issues with styles / css #2047

Open
konstantinschuette opened this issue Jul 3, 2024 · 3 comments
Open

Multiple issues with styles / css #2047

konstantinschuette opened this issue Jul 3, 2024 · 3 comments
Labels

Comments

@konstantinschuette
Copy link

Describe the bug
I have two issues:

  1. You can't override minifyStyles to be false
  2. minifyStyles just removes the styles in a specific case

To Reproduce
I'm using this config. Even if i set minifyStyles: false it still applies changes to <style> tags

module.exports = {
  floatPrecision: "0",
  gzip: false,
  plugins: [
    {
      name: "preset-default",
      params: {
        overrides: {
          cleanupIds: false,
          removeViewBox: false,

          // aka. Collapse useless groups
          collapseGroups: false,

          // aka. Shapes to (smaller) paths
          convertShapeToPath: false,

          // aka. Remove unneeded group attrs
          removeNonInheritableGroupAttrs: false,

          minifyStyles: false
        },
      },
    },
  ],
};

For the second issue i'm using this SVG and the config from above:

<?xml version="1.0" encoding="utf-8"?>
<svg version="1.1" viewBox="0 0 1417.3 1417.3" xmlns="http://www.w3.org/2000/svg">
 <style>
    #svg-3007386279 {
      .cls-1 {
        fill: #8d3013;
        stroke: #8d3013;
      }
    }
 </style>
</svg>

Which results into:

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1417 1417"/>

When I remove the wrapping element #svg-3007386279, it still keeps the styles.

Expected behavior
With the config I provided, I would expect no css changes to be made.
Also I expect wrapping elements to not cause any issues, like getting rid of all styles.

Desktop (please complete the following information):

  • SVGO Version 3.3.2
  • NodeJs Version 20.11.1
  • OS: macOS 14.2.1 (23C71)
@KTibow
Copy link
Contributor

KTibow commented Jul 4, 2024

the second one doesn't appear to have valid css?
edit: actually nesting became a thing within the past year. regardless, it doesn't change anything meaningful within the svg.

@konstantinschuette
Copy link
Author

the second one doesn't appear to have valid css? edit: actually nesting became a thing within the past year. regardless, it doesn't change anything meaningful within the svg.

What do you mean with doesn't change anything meaningful within the svg.?

@KTibow
Copy link
Contributor

KTibow commented Jul 30, 2024

there is no svg-3007386279 or cls-1 that it is styling

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

No branches or pull requests

2 participants