Source:  Twitter logo

I'm using vite 0.16.6 and wanted to migrated a vuepress site to using vite.

However I was unsure how to configure vite to using tailwindcss.

in my index.css

@tailwind base;
@tailwind components;
@tailwind utilities;

#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}

After some digging, looks like that we have to include a postcss.config.js in the root directory of the application

module.exports = {
  plugins: [
    // ...
    require('tailwindcss'),
    require('autoprefixer'),
    // ...
  ]
}
11 users liked answer #0dislike answer #011
Denis Tsoi profile pic
Denis Tsoi

I wrote a vite tailwind plugin https://github.com/axe-me/vite-plugin-tailwind

it enabled the jit compiler by default and it also have a tailwind config viewer

2 users liked answer #1dislike answer #12
AXE profile pic
AXE
yarn add tailwindcss @tailwindcss/typography @tailwindcss/ui -D

yarn tailwind init note : you can use npm

crate file : postcss.config.js and add :

module.exports={
 plugins: [
  require('tailwindcss'),
  require('autoprefixer'),
  ]
 }

Replace the contents of src/index.css file with:

@import "tailwindcss/base";
@import "tailwindcss/components";
@import "tailwindcss/utilities";
1 users liked answer #2dislike answer #21
kadiro profile pic
kadiro

Copyright © 2022 QueryThreads

All content on Query Threads is licensed under the Creative Commons Attribution-ShareAlike 3.0 license (CC BY-SA 3.0).