Created
March 31, 2019 12:07
-
-
Save LinusBorg/44b8de3455c8f3a638c4425f83fb8b12 to your computer and use it in GitHub Desktop.
purge css with tailwind and Vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Props: https://dev.to/_mikhailbot/vue-cli-3-tailwindcss-and-purgecss-1d1k | |
const tailwindcss = require('tailwindcss') | |
const purgecss = require('@fullhuman/postcss-purgecss') | |
const autoprefixer = require('autoprefixer') | |
const postcssImport = require('postcss-import') | |
module.exports = { | |
plugins: [ | |
postcssImport, | |
tailwindcss('./tailwind.js'), | |
purgecss({ | |
content: ['./src/**/*.vue'], | |
extractors: [ | |
{ | |
extractor: class TailwindExtractor { | |
static extract(content) { | |
return content.match(/[A-z0-9-:\/]+/g) || []; | |
} | |
}, | |
extensions: ['vue'] | |
} | |
] | |
}), | |
autoprefixer | |
] | |
} |
That Gist is 3 years old. Tailwind iterated 2 major versions since then, and I think purgeCSS no longer required since Tailwind 2 implements all of that itself.
Yeah... the v2 implemented it, then they killed it in v3 so this gist became needed again :) I made it work with the latest version (3.2.x).
https://github.com/padcom/tailwind-example/blob/master/postcss.config.js
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Doesn't work with Vite 4.0.4, Node.js 19.x and tailwindcss 3.2.4
tailwind.config.js: