Vue + Tailwind + PurgeCSS — The right way


Universal PurgeCSS caveats

Include all files that consume CSS in the content array

Never string-concatinate classnames

Universal Vue.js + TailwindCSS caveats

Class conflicts

External code that consumes classes

TailwindCSS caveats

Special characters in classnames

Vue.js caveats

Single-file components contain <style> blocks

Autogenerated classnames

Final configuration

content: [ './public/**/*.html', './src/**/*.vue' ],
defaultExtractor: (content) => {
const contentWithoutStyleBlocks = content.replace(/<style[^]+?<\/style>/gi, '')
return contentWithoutStyleBlocks.match(/[A-Za-z0-9-_/:]*[A-Za-z0-9-_/]+/g) || []
whitelistPatterns: [ /-(leave|enter|appear)(|-(to|from|active))$/, /^(?!cursor-move).+-move$/, /^router-link(|-exact)-active$/ ],




Language learning and coding.

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store


Language learning and coding.