DEV Community

Jiawei Li
Jiawei Li

Posted on

3 3

Reduce Duplicated Styled Components? Check Here

I made a post 2 weeks ago about how to reduce CSS automatically: Scan Duplicated & Similar CSS and the github source: css-checker

Few days ago, there was an issue asking for styled components support. It's very hard to found few sources about processing styled components using golang, so I have to use regex to detect them and use original css-checker functions to detect diffs in styled-components.

Fortunately, it goes well to use css-checker for styled-components checking and you can use this now for styled-components check. It can check similar lines and prints those blocks with diff lines highlighted.

Install

  • You can access to the package via go install:
go install github.com/ruilisi/css-checker@latest
Enter fullscreen mode Exit fullscreen mode

(With go version before 1.17, use go get github.com/ruilisi/css-checker). Or download from releases

  • Or from npm:
npm install -g css-checker-kit
Enter fullscreen mode Exit fullscreen mode

Start Checking

  • cd to your Project Path. Then just run:
css-checker -styled
Enter fullscreen mode Exit fullscreen mode
  • If only need to check styled-components:
css-checker -css=false -styled
Enter fullscreen mode Exit fullscreen mode

For other usages, please refer to github: CSS-Checker

Demo

Image description

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay