Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v4] vite build --watch only compile html classes right on the init run #14106

Closed
KartoffelToby opened this issue Aug 1, 2024 · 4 comments · Fixed by #14269
Closed

[v4] vite build --watch only compile html classes right on the init run #14106

KartoffelToby opened this issue Aug 1, 2024 · 4 comments · Fixed by #14269

Comments

@KartoffelToby
Copy link

What version of Tailwind CSS are you using?

v4

What build tool (or framework if it abstracts the build tool) are you using?

Plain vite Projekt with css/html Input files in rollup config

What version of Node.js are you using?

v20.11.0

What browser are you using?

Chrome

What operating system are you using?

Linux Debian

Describe your issue

I have some css files ans HTML files. The HTML contains some tailwindcss classes like p-2 etc. If i run vite build --watch the first build is correct. And the p-2 css Definition is in the Output css. But if i change the classes in the HTML it recompiles but dont get the new classes. If i use @apply in my source css file the Compiler works every time. So must be a bug in the HTML stuff.

@Massa-Albani4
Copy link

Massa-Albani4 commented Aug 3, 2024

try adding purge: ["./src/**/*.{html,js}"], in the tailwind config file

@KartoffelToby
Copy link
Author

KartoffelToby commented Aug 3, 2024

@Massa-Albani4 Its the vite Plugin from v4 no tailwindcss config anymore

@philipp-spiess
Copy link
Member

@KartoffelToby Heya! Do you have a repro that you can share? We've been looking into the Vite plugin just last week and as a result of that also added a new integration test that does cover changing a .html file in watch mode if you need a starting point.

@muhharuntahir
Copy link

muhharuntahir commented Aug 7, 2024

1. Check Vite Configuration:
Ensure that your Vite configuration is set up correctly to watch for changes in HTML files. Your vite.config.js should include the HTML files in the build.rollupOptions.input configuration.

import { defineConfig } from "vite"
import path from "path"

export default defineConfig({
  build: {
    rollupOptions: {
      input: {
        main: path.resolve(__dirname, "index.html"),
        // Add other HTML entry points here
      }
    }
  }
})

/
/
2. Tailwind CSS Configuration:
Make sure your tailwind.config.js is correctly configured to purge unused styles from the correct files. For example:

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

/
/

3. Update Dependencies:
Ensure all dependencies are up-to-date, including Vite and Tailwind CSS. Run:
npm update

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants