Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/twelve-pans-dress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@vanilla-extract/vite-plugin': patch
---

Fixes a bug where Vanilla Extract files with extensions other than `css.ts` were not being invalidated during HMR
6 changes: 6 additions & 0 deletions fixtures/features/src/html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,9 @@ export default `
<div id="${testNodes.styleCompositionInSelector}" class="${styles.styleCompositionInSelector}">Style composition in selector</div>
<div id="${testNodes.styleVariantsCompositionInSelector}" class="${styles.styleVariantsCompositionInSelector.variant}">Style variants composition in selector</div>
`;

// @ts-expect-error Vite env not defined
if (import.meta.hot) {
// @ts-expect-error Vite env not defined
import.meta.hot.accept();
}
Comment on lines +14 to +18
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self-accepting is fine here.

7 changes: 0 additions & 7 deletions fixtures/features/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,3 @@ function render() {
}

render();

// Uncomment to enable HMR with Vite
// if (import.meta.hot) {
// import.meta.hot.accept('./features.css', () => {
// render();
// });
// }
Comment on lines -9 to -14
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't belong here anymore since this file no longer imports features.css.ts.

2 changes: 1 addition & 1 deletion packages/vite-plugin/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ export function vanillaExtractPlugin({
// We have to invalidate the virtual module & deps, not the real one we just transformed
// The deps have to be invalidated in case one of them changing was the trigger causing
// the current transformation
if (file.endsWith('.css.ts')) {
if (cssFileFilter.test(file)) {
invalidateModule(fileIdToVirtualId(file));
}
}
Expand Down