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

:where and :is selectors will be always removed. #320

Closed
leifmarcus opened this issue Sep 14, 2023 · 4 comments · Fixed by #327
Closed

:where and :is selectors will be always removed. #320

leifmarcus opened this issue Sep 14, 2023 · 4 comments · Fixed by #327
Assignees
Labels
astro-purgecss Issues related to astro-purgecss package bug Something isn't working

Comments

@leifmarcus
Copy link

leifmarcus commented Sep 14, 2023

Describe the bug
There is a bug in purgecss at the moment (FullHuman/purgecss#978). This seems to be fixed in later versions.

To Reproduce
Have any html file that contains a class name, that is wrapped in :is(.any-class) or :where(.any-class) and run purgecss with the default settings on this html file.

Expected behavior
selector with :where or :is should only be removed, if it is not used inside the html file.

I just wanted to mention this here, as the next version of purgecss seems to fix this issue.

@leifmarcus leifmarcus added the bug Something isn't working label Sep 14, 2023
@leifmarcus
Copy link
Author

This is about the astro-purgecss integration. The question is, if there is a way to solve this issue until the bug is fixed in the core package.

@the-dijkstra
Copy link
Member

I don't think it's possible to solve this issue on this integration level, but I see that in the original issue, there was a workaroud mentioned: FullHuman/purgecss#978 (comment)

This integration allows you to pass options to the underlying postcss

export default defineConfig({
  integrations: [
    purgecss({
      fontFace: true,
      keyframes: true,
      safelist: ['random', 'yep', 'button', /^nav-/],
      blocklist: ['usedClass', /^nav-/],
      content: [
        process.cwd() + '/src/**/*.{astro,vue}' // Watching astro and vue sources (for SSR, read the note below)
      ]
    })
  ]
});

@the-dijkstra the-dijkstra added the astro-purgecss Issues related to astro-purgecss package label Sep 14, 2023
@leifmarcus
Copy link
Author

@the-dijkstra, Thanks, I use this approach already with the workaround. An Idea would be to define purgecss as peerDependency, so that it's easier to update to the latest version of purgecss when the fix is released.

@the-dijkstra
Copy link
Member

Thanks man, well this repository uses renovate to auto update dependencies so be sure when the latest version of purgecss is published this plugin will get updated right after. I will look though into the idea of making in it as peer dependecy.

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 bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants