Skip to content

Commit 2232ef4

Browse files
authored
vite: Fix CSS output not updating in watch mode (#1397)
1 parent 1381e54 commit 2232ef4

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

.changeset/gentle-ligers-act.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@vanilla-extract/vite-plugin': patch
3+
---
4+
5+
Fixes a bug that was causing output CSS files to not update during watch mode

packages/vite-plugin/src/index.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,14 @@ export function vanillaExtractPlugin({
156156
}
157157
},
158158
buildEnd() {
159-
compiler?.close();
159+
// When using the rollup watcher, we don't want to close the compiler after every build.
160+
// Instead, we close it when the watcher is closed via the closeWatcher hook.
161+
if (!config.build.watch) {
162+
compiler?.close();
163+
}
164+
},
165+
closeWatcher() {
166+
return compiler?.close();
160167
},
161168
async transform(code, id) {
162169
const [validId] = id.split('?');

0 commit comments

Comments
 (0)