Vue + Tailwindcss config

Vue + Tailwindcss config

How to configure Tailwindcss with Vue

1. Install Tailwind via npm

npm install -D tailwindcss@latest postcss@latest autoprefixer@latest

2. Create your configuration files

npx tailwindcss init -p

3. Configure Tailwind to remove unused styles in production

// tailwind.config.js
module.exports = {
    purge: ['./index.html', './src/**/*.{vue,js,ts,jsx,tsx}'],
    darkMode: false, // or 'media' or 'class'
    theme: {
      extend: {},
    },
    variants: {
      extend: {},
    },
    plugins: [],
  }

4. Include Tailwind in your CSS

/* ./src/index.css */
@tailwind base;
@tailwind components;
@tailwind utilities;

5. Import your CSS in main.js

// src/main.js
import { createApp } from 'vue'
import App from './App.vue'
import './index.css'

createApp(App).mount('#app')