Skip to content

Preserve HTML elements by default when purging unused styles - #2283

Merged
adamwathan merged 1 commit into
masterfrom
purge-safelist-html-elements
Sep 1, 2020
Merged

Preserve HTML elements by default when purging unused styles#2283
adamwathan merged 1 commit into
masterfrom
purge-safelist-html-elements

Conversation

@adamwathan

Copy link
Copy Markdown
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

pikeas commented Sep 22, 2020

Copy link
Copy Markdown

@adamwathan

Copy link
Copy Markdown
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