hdou533 / image-hosting

0 stars 0 forks source link

Tailwind CSS not working #3

Open hdou533 opened 20 hours ago

hdou533 commented 20 hours ago

Manually installed Tailwind and it is not working.

What has been done?

  1. checking the config files tailwind.config.js - content added ["./src/*/.{html,js}"]
  2. Testing text color - not working
  3. Research: gpt

    • create postcss.config.js
    • npm install tailwindcss postcss autoprefixer
    • npx tailwindcss init
    • add CSS to index.css
    • import CSS in main.tsx stackoverflow
    • update your vite.config file

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

      After following the guides from the official [documentation] (https://tailwindcss.com/docs/installation), you may want to check in your package.json file and see under the devDependencies if tailwind is appearing there or not. Also, check in your postcss.config.cjs file and see if the following is there:

          react/77830926#77830926
          module.exports = {
              plugins: {
                  tailwindcss: {},
                 autoprefixer: {},
                 },
             }

      after installed tailwindcss and postcss, generate config files for both of them with the following command

       npm install -D tailwindcss postcss autoprefixer
       npx tailwindcss init -p
  4. Still not working but configs seem all right ![In my case the problem came from tailwind.config.js, index.html was missing from the content.]https://stackoverflow.com/a/78663634/16779281

     export default {
         content: [
            "./index.html",
           "./src/**/*.{js,ts,jsx,tsx}",
         ],
         theme: {
            extend: {},
           },
         plugins: [],
      }

    Found the issue Did not add jsx and TSX to the content

hdou533 commented 20 hours ago

Fix:

  1. add and setup postcss.config.js
  2. ensure all file types are included in tailwind.config.js