Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow overriding purgecss options #370

Merged
merged 2 commits into from
Jan 20, 2024
Merged

Allow overriding purgecss options #370

merged 2 commits into from
Jan 20, 2024

Conversation

gavar
Copy link
Contributor

@gavar gavar commented Jan 13, 2024

this pull request updates purgecss regex to avoid deleting styles that are actually in use.
https://v2.tailwindcss.com/docs/optimizing-for-production#writing-purgeable-html

UPDATE:
it was decided to allow providing custom options to override existing ones instead of introducing a breaking change

@mhdcodes
Copy link
Member

Hey @gavar thanks for the PR, I don't know how I feel about this, wouldn't this make it more fuzzy ?
image

IMO, this defeats the purpose of purging CSS, if the content of any tags contains any words that mtaches with a css class name, that css class won't be purged ?

@mhdcodes mhdcodes self-assigned this Jan 13, 2024
@gavar
Copy link
Contributor Author

gavar commented Jan 18, 2024

@the-dijkstra thanks, it does make sense! I'll refine a regex to include only class names. At the moment, I wasn't able to use astro-purgecss` as it was removing classes that were actually necessary.

@mhdcodes
Copy link
Member

@gavar I think I need to refactor the options to allow for passing extra extractors, to allow for people using tailwind to customize the logic.
https://purgecss.com/extractors.html#using-an-extractor

@gavar
Copy link
Contributor Author

gavar commented Jan 19, 2024

@the-dijkstra I've updated the configuration to allow overriding any PurgeCSS option but preserved the logic of merging options.content

mhdcodes
mhdcodes previously approved these changes Jan 19, 2024
@mhdcodes
Copy link
Member

Hey @gavar thanks for the changes 🙏 , I will merge this if you can please add the relevant changeset.

pnpm run changeset

Or if you are using npm

npm run changeset

Note: This should be a minor version bump.

@mhdcodes mhdcodes added astro-purgecss Issues related to astro-purgecss package enhancement New feature or request labels Jan 19, 2024
@mhdcodes mhdcodes changed the title fix: tailwind extractor feat: allow to override purgecss options Jan 19, 2024
@gavar
Copy link
Contributor Author

gavar commented Jan 19, 2024

Thanks, @the-dijkstra. I hope the changeset has been generated correctly. I'm not sure how to enforce a minor version change, so I've altered the last commit to specify a 'minor' change bump manually.

@mhdcodes mhdcodes changed the title feat: allow to override purgecss options Allow to overriding purgecss options Jan 20, 2024
@mhdcodes mhdcodes changed the title Allow to overriding purgecss options Allow overriding purgecss options Jan 20, 2024
@mhdcodes mhdcodes merged commit 063add6 into codiume:main Jan 20, 2024
3 checks passed
@github-actions github-actions bot mentioned this pull request Jan 20, 2024
@mhdcodes
Copy link
Member

Hey @gavar thanks for taking the time to make this PR 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
astro-purgecss Issues related to astro-purgecss package enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants