Skip to content

Instantly share code, notes, and snippets.

@samir
Last active August 26, 2020 00:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samir/cef2701fefd378e35e93e9e1d3c4428e to your computer and use it in GitHub Desktop.
Save samir/cef2701fefd378e35e93e9e1d3c4428e to your computer and use it in GitHub Desktop.
Setup Tailwind with Vue.js
const autoprefixer = require('autoprefixer')
const tailwindcss = require('tailwindcss')
const postcssPurgecss = require('@fullhuman/postcss-purgecss')
const purgecss = postcssPurgecss({
// Specify the paths to all of the template files in your project.
content: [
'./public/**/*.html',
'./src/**/*.vue'
],
// Include any special characters you're using in this regular expression.
// See: https://tailwindcss.com/docs/controlling-file-size/#understanding-the-regex
defaultExtractor: content => content.match(/[\w-/:]+(?<!:)/g) || [],
// Whitelist auto generated classes for transitions and router links.
// From: https://github.com/ky-is/vue-cli-plugin-tailwind
whitelistPatterns: [
/-(leave|enter|appear)(|-(to|from|active))$/,
/^(?!(|.*?:)cursor-move).+-move$/,
/^router-link(|-exact)-active$/
]
})
module.exports = {
plugins: [
tailwindcss,
autoprefixer,
...process.env.NODE_ENV === 'production'
? [purgecss]
: []
]
}
#!/bin/bash
npm install tailwindcss postcss-cli autoprefixer @fullhuman/postcss-purgecss --save-dev
mkdir src/assets/styles
touch src/assets/styles/index.css
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment