Skip to content
This repository has been archived by the owner on Feb 26, 2023. It is now read-only.

remove unused classnames in tabler.css using PostCSS #860

Open
TheHadiAhmadi opened this issue Jan 13, 2023 · 4 comments
Open

remove unused classnames in tabler.css using PostCSS #860

TheHadiAhmadi opened this issue Jan 13, 2023 · 4 comments
Assignees

Comments

@TheHadiAhmadi
Copy link
Collaborator

https://github.com/jacobp100/postcss-remove-classes
using this plugin it is possible to remove bootstrap's default classes like 'btn', 'card', 'mb-2', ....

maybe useful for our use-case:
https://github.com/itaoyuta/postcss-selector-replace

also this plugin removes css classes.
https://github.com/AoDev/css-byebye
https://github.com/AoDev/css-byebye/blob/master/lib/css-byebye.js

we can write a PostCSS plugin which transform tabler.css to a simpler css file with only .u-* classes
something like this:
postcss.config.cjs

module.exports = {
    plugins: [
        ubeacCSS({
            classesToSave: [/u-*/] // save all classes which starts with 'u-'
        )
    ]
}

tabler.css

.btn, .u-button {
   ....button styles
}
.btn-primary, .u-button-color-primary {
   ....primary color
}
.some-class-that-only-tabler-uses, .and-we-dont-extend {
  ...some styles
}

output:

.u-button {
   ....button styles
}
.u-button-color-primary {
   ....primary color
}
@TheHadiAhmadi
Copy link
Collaborator Author

https://github.com/AoDev/css-byebye
I think using this plugin we can tell that remove all classes which doesn't start with 'u-' using some regex pattern.

@TheHadiAhmadi
Copy link
Collaborator Author

^(?!(?:u-)\b)(.*)$

@TheHadiAhmadi
Copy link
Collaborator Author

@TheHadiAhmadi TheHadiAhmadi self-assigned this Jan 13, 2023
@pournasserian
Copy link
Contributor

Also see this one:
https://www.npmjs.com/package/minify

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

No branches or pull requests

2 participants