DEV Community

Jiawei Li
Jiawei Li

Posted on

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

Discussion (0)