Skip to content

Commit 4fb9a2c

Browse files
author
Ben Jervis
authored
Vite hmr fix (#781)
1 parent 7781d9f commit 4fb9a2c

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

.changeset/five-students-try.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+
Adds a check for the existence of import.meta.hot before attempting to add an event listener to inject styles

packages/vite-plugin/src/index.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,11 @@ export function vanillaExtractPlugin({
114114
115115
inject(${JSON.stringify(css)});
116116
117-
import.meta.hot.on('${styleUpdateEvent(validId)}', (css) => {
118-
inject(css);
119-
});
117+
if (import.meta.hot) {
118+
import.meta.hot.on('${styleUpdateEvent(validId)}', (css) => {
119+
inject(css);
120+
});
121+
}
120122
`;
121123
},
122124
async transform(code, id, ssrParam) {

0 commit comments

Comments
 (0)