From e8f4e13da63afdcab9f04b80803cb2c06f494a77 Mon Sep 17 00:00:00 2001 From: Adam Skoufis Date: Mon, 29 Apr 2024 21:50:10 +1000 Subject: [PATCH] Fix vite watch mode --- .changeset/gentle-ligers-act.md | 5 +++++ packages/vite-plugin/src/index.ts | 9 ++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 .changeset/gentle-ligers-act.md diff --git a/.changeset/gentle-ligers-act.md b/.changeset/gentle-ligers-act.md new file mode 100644 index 00000000..d6311121 --- /dev/null +++ b/.changeset/gentle-ligers-act.md @@ -0,0 +1,5 @@ +--- +'@vanilla-extract/vite-plugin': patch +--- + +Fixes a bug that was causing output CSS files to not update during watch mode diff --git a/packages/vite-plugin/src/index.ts b/packages/vite-plugin/src/index.ts index 1dd2cb99..c73e13e3 100644 --- a/packages/vite-plugin/src/index.ts +++ b/packages/vite-plugin/src/index.ts @@ -156,7 +156,14 @@ export function vanillaExtractPlugin({ } }, buildEnd() { - compiler?.close(); + // When using the rollup watcher, we don't want to close the compiler after every build. + // Instead, we close it when the watcher is closed via the closeWatcher hook. + if (!config.build.watch) { + compiler?.close(); + } + }, + closeWatcher() { + return compiler?.close(); }, async transform(code, id) { const [validId] = id.split('?');