Skip to content

Commit 13ff78e

Browse files
authored
Merge pull request #70 from dev-five-git/fix-convert
Fix hmr issue
2 parents 44953b8 + e3d29ed commit 13ff78e

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

.changeset/stale-cherries-drum.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@devup-ui/vite-plugin": patch
3+
---
4+
5+
Fix hmr issue

packages/vite-plugin/src/plugin.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export function DevupUI({
6161
}
6262
return {
6363
name: 'devup-ui',
64-
config: () => {
64+
config() {
6565
return {
6666
server: {
6767
watch: {
@@ -98,6 +98,17 @@ export function DevupUI({
9898
writeFileSync(cssFile, css, {
9999
encoding: 'utf-8',
100100
})
101+
return {
102+
code: `${retCode}
103+
const exists = !!document.getElementById('devup-ui');
104+
const style = document.getElementById('devup-ui') || document.createElement('style');
105+
style.id = 'devup-ui';
106+
style.textContent = \`
107+
${css}
108+
\`;
109+
if (!exists) document.head.appendChild(style);
110+
`,
111+
}
101112
}
102113
return {
103114
code: retCode,

0 commit comments

Comments
 (0)