A CLI tool to clean duplicate CSS/SCSS properties, keeping the last occurrence.
npm install --save-dev @aakashvaa/css-cleaner{
"scripts": {
"clean": "css-cleaner src --recursive",
"clean:fix": "css-cleaner src --recursive --fix"
}
}- src => It's the relative path from the project root where the css-cleaner script will run.
{
"scripts": {
"clean": "npx @aakashvaa/css-cleaner src --recursive",
"clean:fix": "npx @aakashvaa/css-cleaner src --recursive --fix"
}
}
- Check for duplicates:
npm run clean- Fix duplicates:
npm run clean:fix
-
clean:- Scans the
srcdirectory and all its subdirectories for.cssand.scssfiles. - Logs duplicate CSS/SCSS properties without modifying the files.
- Scans the
-
clean:fix:- Scans the
srcdirectory and its subdirectories for.cssand.scssfiles. - Automatically removes duplicate properties and overwrites the files.
- Scans the
css-cleaner <path-to-your-[.css/.scss] file>- example : css-cleaner styles.css/styles.scss
You can also run the tool directly if it’s installed globally:
- check:
css-cleaner <relative path to your styles> -r- fix:
css-cleaner <relative path to your styles> -r --fixFor detailed command options, use:
css-cleaner --help