question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Class names are getting changed. I need them to remain the same.

See original GitHub issue

💬 Questions and Help

I am importing several svgs into my project using svgr. Every svg file has classes called icon-fill or icon-stroke that allows them to be colored appropriately.

Somewhere else in my project I have this css set:

   .icon-stroke {
      stroke: currentColor;
    }
    .icon-fill {
      fill: currentColor;
    }

This makes the icons all correctly inherit the color property of their parent.


The problem

is that all the class names in my svgs are getting changed to have the file name prepended to the class name. For example, one of the file names is ChevronLeft.svg so the class name is getting rewritten to ChevronLeft_svg__icon-fill. This is causing my svgs to no longer be colored correctly.

I have looked through the docs and I do not see a way to turn this off.

Is there a way I can fix this so that the class names are left as is?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
gregbergecommented, Feb 23, 2022

To clarify, noSvgo: false is not correct. svgo: false is.

1reaction
jisaackscommented, Feb 14, 2022

@guillaumebrunerie Thanks for pointing that out, For anyone else who comes upon this, it was tricky to figure out how to actually apply it.

For example:

import svgr from '@svgr/rollup'

export default {
  plugins: [
    svgr({
      noSvgo: true,
    })
  ]
}

Does not work. I have also tried '--no-svgo': true and 'no-svgo': true here.

I also tried adding this to my project root

// svgr.config.js
module.exports = {
  noSvgo: true
}

Also tried adding this to my package.json:

"svgr": {
    "noSvgo": true
  }

None of the above worked, however this did (added to project root):

// svgo.config.js
module.exports = {
  prefixIds: false
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to change the name appearing in the class room?
My child has logged into classrom through my google account. My google id and photo is appearing in the class room. How to...
Read more >
css - class overrule when two classes assigned to one div
Multiple classes can be assigned to a div. Just separate them in the class name with spaces like this: <div class="rule1 rule2 ...
Read more >
Change Class Names Of Multiple Divs With Same ... - SitePoint
Hi, I have a situation where PHP is creating a document that has code blocks that contain the same class names each time...
Read more >
CSS Class Names to Prevent Refactoring - Sparkbox
This is because we can't predict the future. A class name might make perfect sense one day, then the design changes, and it's...
Read more >
Possibly class name change over time. What approach to take?
But on your original point, businesses and requirements change. Therefore, so can code. It's entirely acceptable to rename classes and methods if logic...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found