I have installed Vite with Tailwind. But after installing Tailwind , when I change the index.html file, the Vite server does not auto reload. It reloads when I save the file main.js.
tailwind.config.js
module.exports = {
content: ['./*.html', './src/**/*.{vue,js,ts,jsx,tsx}'],
theme: {
extend: {},
},
plugins: [],
};
postcss.config.js
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
main.js
import './style.css';
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite App</title>
</head>
<body>
<div id="app"></div>
<h1 class="text-blue-500">helo</h1>
<script type="module" src="/main.js"></script>
</body>
</html>
style.css
@tailwind base;
@tailwind components;
@tailwind utilities;
If it's the
<h1 class="text-blue-500">helo</h1>
you expect to see, I had the same problem. Make sure you include the stylesheet inindex.html
:Tailwind is building properly when
main.js
gets built and updated withVite
and the stylesheet gets injected, but that's not happening forindex.html
when it has no reference to the stylesheet.