question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

‘Basic usage’ of purging removes pseudo-elements from modern-normalize

See original GitHub issue

Many thanks for making Tailwind available.

When purging is enabled as per the basic usage in the documentation, pseudo-element selectors such as ::-moz-focus-inner are removed from the modern-normalize styles. (Selectors such as [type='reset'] are also removed from modern-normalize styles, but I expect this is because no such elements exist in the content I’m feeding purge, and so probably makes sense.)

To avoid this, I’m using layers: ['components', 'utilities'] in the purge config. This ability to restrict purging is mentioned in the documentation, but the connection to preserving the reset is not made clear, which I expect means many users of Tailwind will be missing normalizing styles without realising.

Can/should the base layer be exempted from purging by default?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

7reactions
bjuppacommented, Jan 21, 2021

For anyone in need of a quick fix, here’s an example tailwind.config.js with a safelist option added to keep the pseudo element selectors starting with : from being purged:

const defaultTheme = require('tailwindcss/defaultTheme');

module.exports = {
    purge: {
        content: [
            './vendor/laravel/jetstream/**/*.blade.php',
            './storage/framework/views/*.php',
            './resources/views/**/*.blade.php',
        ],
        options: {
            safelist: [/^:/],
        },
    },

    // ...
}

Perhaps it’d make sense for Tailwind to add the pattern /^:/ by default to purgecss’ safelist config? If it is possible to push a regex onto the preserved list as @TheEskhaton suggested, I think that’d be great!

Here’s the full list of selectors used in Tailwind you’d expect to be kept but are currently purged:

  • ::-moz-focus-inner
  • :-moz-focusring
  • :-moz-ui-invalid
  • ::-webkit-inner-spin-button+ ::-webkit-outer-spin-button
  • ::-webkit-search-decoration
  • ::-webkit-file-upload-button
  • ::-webkit-datetime-edit-fields-wrapper
  • ::-webkit-date-and-time-value
3reactions
adamwathancommented, Dec 12, 2020

Good catch, we’ll look into coming up with a solution for this. I think ideally we should try to find a way to make PurgeCSS only purge class selectors by default and not base elements or attribute selectors.

Read more comments on GitHub >

github_iconTop Results From Across the Web

CSS: How to remove pseudo elements (after, before,...)?
I want to add that: jQuery is already used on the page. and I do not want to include or remove files containing...
Read more >
tailwindcss | Yarn - Package Manager
Important: This documentation covers modern versions of Yarn. For 1.x docs, see classic.yarnpkg.com. Yarn.
Read more >
Is Tailwind CSS the Future of CSS Frameworks?
Anyone with basic CSS skills and some knowledge of tooling can use Tailwind CSS, but it's mostly used by front-end developers with an...
Read more >
An Organic Chemist's Guide to N-Nitrosamines
N-Nitrosamines are a class of compounds notorious both for the potent carcinogenicity of many of its members and for their widespread ...
Read more >
Evidence of long-term purging of mutation load in killer ...
Non-synonymous mutations purged in modern Norwegian killer whale ... We used pseudo-haploid genotype calls of autosomal regions in our ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found