@unocss/vite 0.23.0 → 0.24.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -8
- package/dist/index.cjs +17 -18
- package/dist/index.mjs +17 -18
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
The Vite plugin for UnoCSS. Ships with the `unocss` package.
|
|
4
4
|
|
|
5
|
-
> This plugin does not come with any default presets. You are building a meta framework on top of UnoCSS, see [this file](https://github.com/
|
|
5
|
+
> This plugin does not come with any default presets. You are building a meta framework on top of UnoCSS, see [this file](https://github.com/unocss/unocss/blob/main/packages/unocss/src/vite.ts) for an example to bind the default presets.
|
|
6
6
|
|
|
7
7
|
## Installation
|
|
8
8
|
|
|
@@ -121,7 +121,7 @@ export default {
|
|
|
121
121
|
}
|
|
122
122
|
```
|
|
123
123
|
|
|
124
|
-
You have a `React` example project on [test/fixtures/vite-react](https://github.com/
|
|
124
|
+
You have a `React` example project on [test/fixtures/vite-react](https://github.com/unocss/unocss/tree/main/test/fixtures/vite-react) directory using both plugins, check the scripts on `package.json` and its Vite configuration file.
|
|
125
125
|
|
|
126
126
|
### Preact
|
|
127
127
|
|
|
@@ -178,7 +178,7 @@ export default {
|
|
|
178
178
|
}
|
|
179
179
|
```
|
|
180
180
|
|
|
181
|
-
You have a `Preact` example project on [test/fixtures/vite-preact](https://github.com/
|
|
181
|
+
You have a `Preact` example project on [test/fixtures/vite-preact](https://github.com/unocss/unocss/tree/main/test/fixtures/vite-preact) directory using both plugins, check the scripts on `package.json` and its Vite configuration file.
|
|
182
182
|
|
|
183
183
|
### Svelte
|
|
184
184
|
|
|
@@ -205,7 +205,7 @@ export default {
|
|
|
205
205
|
}
|
|
206
206
|
```
|
|
207
207
|
|
|
208
|
-
You have a `Vite + Svelte` example project on [test/fixtures/vite-svelte](https://github.com/
|
|
208
|
+
You have a `Vite + Svelte` example project on [test/fixtures/vite-svelte](https://github.com/unocss/unocss/tree/main/test/fixtures/vite-svelte) directory.
|
|
209
209
|
|
|
210
210
|
### Sveltekit
|
|
211
211
|
|
|
@@ -241,7 +241,7 @@ const config = {
|
|
|
241
241
|
}
|
|
242
242
|
```
|
|
243
243
|
|
|
244
|
-
You have a `SvelteKit` example project on [test/fixtures/sveltekit](https://github.com/
|
|
244
|
+
You have a `SvelteKit` example project on [test/fixtures/sveltekit](https://github.com/unocss/unocss/tree/main/test/fixtures/sveltekit) directory.
|
|
245
245
|
|
|
246
246
|
### Web Components
|
|
247
247
|
|
|
@@ -290,7 +290,7 @@ export class MyElement extends LitElement {
|
|
|
290
290
|
}
|
|
291
291
|
```
|
|
292
292
|
|
|
293
|
-
You have a `Web Components` example project on [test/fixtures/vite-lit](https://github.com/
|
|
293
|
+
You have a `Web Components` example project on [test/fixtures/vite-lit](https://github.com/unocss/unocss/tree/main/test/fixtures/vite-lit) directory.
|
|
294
294
|
|
|
295
295
|
#### `::part` built-in support
|
|
296
296
|
|
|
@@ -362,7 +362,7 @@ export default {
|
|
|
362
362
|
}
|
|
363
363
|
```
|
|
364
364
|
|
|
365
|
-
You have a `Vite + Solid` example project on [test/fixtures/vite-solid](https://github.com/
|
|
365
|
+
You have a `Vite + Solid` example project on [test/fixtures/vite-solid](https://github.com/unocss/unocss/tree/main/test/fixtures/vite-solid) directory.
|
|
366
366
|
|
|
367
367
|
### Elm
|
|
368
368
|
|
|
@@ -384,7 +384,7 @@ export default defineConfig({
|
|
|
384
384
|
})
|
|
385
385
|
```
|
|
386
386
|
|
|
387
|
-
You have a `Vite + Elm` example project on [test/fixtures/vite-elm](https://github.com/
|
|
387
|
+
You have a `Vite + Elm` example project on [test/fixtures/vite-elm](https://github.com/unocss/unocss/tree/main/test/fixtures/vite-elm) directory.
|
|
388
388
|
|
|
389
389
|
## License
|
|
390
390
|
|
package/dist/index.cjs
CHANGED
|
@@ -242,9 +242,8 @@ function GlobalModeBuildPlugin({ uno, ready, extract, tokens, modules, filter })
|
|
|
242
242
|
];
|
|
243
243
|
}
|
|
244
244
|
|
|
245
|
-
const
|
|
246
|
-
|
|
247
|
-
const WARN_TIMEOUT = 2e3;
|
|
245
|
+
const WARN_TIMEOUT = 3e3;
|
|
246
|
+
const WS_EVENT_PREFIX = "custom:unocss:";
|
|
248
247
|
function GlobalModeDevPlugin({ uno, tokens, onInvalidate, extract, filter }) {
|
|
249
248
|
const servers = [];
|
|
250
249
|
let base = "";
|
|
@@ -311,20 +310,16 @@ function GlobalModeDevPlugin({ uno, tokens, onInvalidate, extract, filter }) {
|
|
|
311
310
|
configResolved,
|
|
312
311
|
async configureServer(_server) {
|
|
313
312
|
servers.push(_server);
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
const servedTime = +
|
|
313
|
+
setWarnTimer();
|
|
314
|
+
_server.ws.on("connection", (ws) => {
|
|
315
|
+
ws.on("message", (msg) => {
|
|
316
|
+
const message = String(msg);
|
|
317
|
+
if (!message.startsWith(WS_EVENT_PREFIX))
|
|
318
|
+
return;
|
|
319
|
+
const servedTime = +message.slice(WS_EVENT_PREFIX.length);
|
|
321
320
|
if (servedTime < lastUpdate)
|
|
322
321
|
invalidate(0);
|
|
323
|
-
|
|
324
|
-
res.end();
|
|
325
|
-
} else {
|
|
326
|
-
return next();
|
|
327
|
-
}
|
|
322
|
+
});
|
|
328
323
|
});
|
|
329
324
|
},
|
|
330
325
|
transform(code, id) {
|
|
@@ -364,9 +359,13 @@ function GlobalModeDevPlugin({ uno, tokens, onInvalidate, extract, filter }) {
|
|
|
364
359
|
},
|
|
365
360
|
enforce: "post",
|
|
366
361
|
transform(code, id) {
|
|
367
|
-
if (
|
|
368
|
-
return
|
|
369
|
-
|
|
362
|
+
if (id.includes("@vite/client") || id.includes("vite/dist/client/client.mjs"))
|
|
363
|
+
return code.replace("return hot", "hot.send = (data) => socket.send(data);return hot;");
|
|
364
|
+
if (entries.has(getPath(id)) && code.includes("import.meta.hot")) {
|
|
365
|
+
const snippet = `
|
|
366
|
+
if (import.meta.hot) { try { import.meta.hot.send('${WS_EVENT_PREFIX}${lastServed}') } catch {} }`;
|
|
367
|
+
return code + snippet;
|
|
368
|
+
}
|
|
370
369
|
}
|
|
371
370
|
}
|
|
372
371
|
];
|
package/dist/index.mjs
CHANGED
|
@@ -234,9 +234,8 @@ function GlobalModeBuildPlugin({ uno, ready, extract, tokens, modules, filter })
|
|
|
234
234
|
];
|
|
235
235
|
}
|
|
236
236
|
|
|
237
|
-
const
|
|
238
|
-
|
|
239
|
-
const WARN_TIMEOUT = 2e3;
|
|
237
|
+
const WARN_TIMEOUT = 3e3;
|
|
238
|
+
const WS_EVENT_PREFIX = "custom:unocss:";
|
|
240
239
|
function GlobalModeDevPlugin({ uno, tokens, onInvalidate, extract, filter }) {
|
|
241
240
|
const servers = [];
|
|
242
241
|
let base = "";
|
|
@@ -303,20 +302,16 @@ function GlobalModeDevPlugin({ uno, tokens, onInvalidate, extract, filter }) {
|
|
|
303
302
|
configResolved,
|
|
304
303
|
async configureServer(_server) {
|
|
305
304
|
servers.push(_server);
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
const servedTime = +
|
|
305
|
+
setWarnTimer();
|
|
306
|
+
_server.ws.on("connection", (ws) => {
|
|
307
|
+
ws.on("message", (msg) => {
|
|
308
|
+
const message = String(msg);
|
|
309
|
+
if (!message.startsWith(WS_EVENT_PREFIX))
|
|
310
|
+
return;
|
|
311
|
+
const servedTime = +message.slice(WS_EVENT_PREFIX.length);
|
|
313
312
|
if (servedTime < lastUpdate)
|
|
314
313
|
invalidate(0);
|
|
315
|
-
|
|
316
|
-
res.end();
|
|
317
|
-
} else {
|
|
318
|
-
return next();
|
|
319
|
-
}
|
|
314
|
+
});
|
|
320
315
|
});
|
|
321
316
|
},
|
|
322
317
|
transform(code, id) {
|
|
@@ -356,9 +351,13 @@ function GlobalModeDevPlugin({ uno, tokens, onInvalidate, extract, filter }) {
|
|
|
356
351
|
},
|
|
357
352
|
enforce: "post",
|
|
358
353
|
transform(code, id) {
|
|
359
|
-
if (
|
|
360
|
-
return
|
|
361
|
-
|
|
354
|
+
if (id.includes("@vite/client") || id.includes("vite/dist/client/client.mjs"))
|
|
355
|
+
return code.replace("return hot", "hot.send = (data) => socket.send(data);return hot;");
|
|
356
|
+
if (entries.has(getPath(id)) && code.includes("import.meta.hot")) {
|
|
357
|
+
const snippet = `
|
|
358
|
+
if (import.meta.hot) { try { import.meta.hot.send('${WS_EVENT_PREFIX}${lastServed}') } catch {} }`;
|
|
359
|
+
return code + snippet;
|
|
360
|
+
}
|
|
362
361
|
}
|
|
363
362
|
}
|
|
364
363
|
];
|
package/package.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unocss/vite",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.3",
|
|
4
4
|
"description": "The Vite plugin for UnoCSS",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"unocss",
|
|
7
7
|
"vite",
|
|
8
8
|
"vite-plugin"
|
|
9
9
|
],
|
|
10
|
-
"homepage": "https://github.com/
|
|
10
|
+
"homepage": "https://github.com/unocss/unocss/tree/main/packages/vite#readme",
|
|
11
11
|
"bugs": {
|
|
12
|
-
"url": "https://github.com/
|
|
12
|
+
"url": "https://github.com/unocss/unocss/issues"
|
|
13
13
|
},
|
|
14
14
|
"repository": {
|
|
15
15
|
"type": "git",
|
|
16
|
-
"url": "git+https://github.com/
|
|
16
|
+
"url": "git+https://github.com/unocss/unocss.git",
|
|
17
17
|
"directory": "packages/vite"
|
|
18
18
|
},
|
|
19
19
|
"funding": "https://github.com/sponsors/antfu",
|
|
@@ -35,10 +35,10 @@
|
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@rollup/pluginutils": "^4.1.2",
|
|
38
|
-
"@unocss/config": "0.
|
|
39
|
-
"@unocss/core": "0.
|
|
40
|
-
"@unocss/inspector": "0.
|
|
41
|
-
"@unocss/scope": "0.
|
|
38
|
+
"@unocss/config": "0.24.3",
|
|
39
|
+
"@unocss/core": "0.24.3",
|
|
40
|
+
"@unocss/inspector": "0.24.3",
|
|
41
|
+
"@unocss/scope": "0.24.3"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"vite": "^2.7.13"
|