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

Preserve HTML elements by default when purging unused styles #2283

Merged
merged 1 commit into from
Sep 1, 2020

Conversation

adamwathan
Copy link
Member

This PR introduces a new preserveHtmlElements option to the purge configuration that allows you to safelist all plain HTML elements, like p, blockquote, body, video, etc.

// tailwind.config.js
module.exports = {
  purge: {
    content: [
      // Paths...
    ],
    preserveHtmlElements: true,
  },
}

This helps avoid accidentally purging things like heading elements when your source files are in a format that compiles to HTML, like markdown (since your markdown won't actually contain the string h1 anywhere).

This option is set to true by default.

On its own this PR won't change anything for anyone really, but I plan to change things to purge all of base, components, and utilities going forward (not just utilities), as this was the only real footgun until now, and with the new typography plugin gaining traction it would be nice to make those styles purgeable by default.

@adamwathan adamwathan merged commit aae71c5 into master Sep 1, 2020
@adamwathan adamwathan deleted the purge-safelist-html-elements branch September 1, 2020 20:20
@pikeas
Copy link

pikeas commented Sep 22, 2020

@adamwathan
Copy link
Member Author

@pikeas Yep not necessary anymore, although what we've done there is even more optimized (but way past the point of diminishing returns).

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

Successfully merging this pull request may close these issues.

2 participants