2

I'm a newbie and I'm gonna lose my mind. I watch every tutorial and read every documents. It's just not work. Anyone knows how to mix tailwind(postcss or cli) and vite ?

I want to use vanilla css with vite, and some tailwind at the same time. But it's recommended not to use tailwindcss CDN with vite.

First I'm creating my vanilla js project with vite and than trying to install tailwind and I do every step as they said. Then I prompt npm run dev voila error

1

4 Answers 4

2

Update your vite.config.js file something like this

import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import tailwindcss from "tailwindcss";
export default defineConfig({
plugins: [react()],
  css: {
   postcss: {
    plugins: [tailwindcss()],
   },
  },
});
0

continue with @NewBie instruction. but at then end for loading the tailwind you have to do two things:

  1. add this to your style.css
    @tailwind base;
    @tailwind components;
    @tailwind utilities;
  1. change your tailwind.config.js as follow
    /** @type {import('tailwindcss').Config} */
    export default {
      content: [
        "index.html",
      ],
      theme: {
        extend: {},
      },
      plugins: [],
    }
0

Installation steps for Vite and React is different.

Hope this link helps.

1
  • As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Jul 7 at 8:32
-1

Run the following commands to use tailwind css with vite + Valinaa js

npm init vite@latest my-vite-project

select Vanilla , Then Enter Select JavaScript

cd my-vite-project

npm install

Install Tailwind CSS and its dependencies using npm:

npm install -D tailwindcss postcss autoprefixer

npx tailwindcss init -p

it will create postcss.config file

like this >

module.exports = {
  plugins: {
    tailwindcss: {},
    autoprefixer: {},
  },
};

and now you can run your project , use this command to run >

npm run dev

Not the answer you're looking for? Browse other questions tagged or ask your own question.