@unocss/vite 0.45.21 → 0.45.23
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/dist/index.cjs +13 -6
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +10 -3
- package/package.json +10 -9
package/dist/index.cjs
CHANGED
|
@@ -8,7 +8,7 @@ const pluginutils = require('@rollup/pluginutils');
|
|
|
8
8
|
const config = require('@unocss/config');
|
|
9
9
|
const crypto = require('crypto');
|
|
10
10
|
const MagicString = require('magic-string');
|
|
11
|
-
const
|
|
11
|
+
const pathe = require('pathe');
|
|
12
12
|
const remapping = require('@ampproject/remapping');
|
|
13
13
|
const fs = require('fs');
|
|
14
14
|
const url = require('url');
|
|
@@ -305,7 +305,7 @@ function GlobalModeBuildPlugin({ uno, ready, extract, tokens, filter, getConfig
|
|
|
305
305
|
}
|
|
306
306
|
},
|
|
307
307
|
async configResolved(config) {
|
|
308
|
-
const distDir =
|
|
308
|
+
const distDir = pathe.resolve(config.root, config.build.outDir);
|
|
309
309
|
cssPostPlugins.set(distDir, config.plugins.find((i) => i.name === "vite:css-post"));
|
|
310
310
|
cssPlugins.set(distDir, config.plugins.find((i) => i.name === "vite:css"));
|
|
311
311
|
await ready;
|
|
@@ -322,7 +322,8 @@ function GlobalModeBuildPlugin({ uno, ready, extract, tokens, filter, getConfig
|
|
|
322
322
|
const fakeCssId = `${chunk.fileName}-unocss-hash.css`;
|
|
323
323
|
css = await applyCssTransform(css, fakeCssId, options.dir);
|
|
324
324
|
const hash = getHash(css);
|
|
325
|
-
|
|
325
|
+
const transformHandler = "handler" in cssPost.transform ? cssPost.transform.handler : cssPost.transform;
|
|
326
|
+
await transformHandler.call({}, getHashPlaceholder(hash), fakeCssId);
|
|
326
327
|
chunk.modules[fakeCssId] = {
|
|
327
328
|
code: null,
|
|
328
329
|
originalLength: 0,
|
|
@@ -463,8 +464,14 @@ function GlobalModeDevPlugin({ uno, tokens, affectedModules, onInvalidate, extra
|
|
|
463
464
|
async configureServer(_server) {
|
|
464
465
|
servers.push(_server);
|
|
465
466
|
_server.ws.on(WS_EVENT_PREFIX, ([layer, hash]) => {
|
|
466
|
-
if (lastServedHash.get(layer) !== hash)
|
|
467
|
+
if (lastServedHash.get(layer) !== hash) {
|
|
467
468
|
sendUpdate(entries);
|
|
469
|
+
} else {
|
|
470
|
+
setTimeout(() => {
|
|
471
|
+
if (lastServedHash.get(layer) !== hash)
|
|
472
|
+
sendUpdate(entries);
|
|
473
|
+
}, 50);
|
|
474
|
+
}
|
|
468
475
|
});
|
|
469
476
|
},
|
|
470
477
|
buildStart() {
|
|
@@ -866,7 +873,7 @@ function createTransformerPlugins(ctx) {
|
|
|
866
873
|
}));
|
|
867
874
|
}
|
|
868
875
|
|
|
869
|
-
const _dirname = typeof __dirname !== "undefined" ? __dirname :
|
|
876
|
+
const _dirname = typeof __dirname !== "undefined" ? __dirname : pathe.dirname(url.fileURLToPath((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('index.cjs', document.baseURI).href))));
|
|
870
877
|
const DEVTOOLS_MODULE_ID = "virtual:unocss-devtools";
|
|
871
878
|
const MOCK_CLASSES_MODULE_ID = "virtual:unocss-mock-classes";
|
|
872
879
|
const MOCK_CLASSES_PATH = "/@unocss/mock-classes";
|
|
@@ -976,7 +983,7 @@ function createDevtoolsPlugin(ctx) {
|
|
|
976
983
|
if (id === DEVTOOLS_PATH) {
|
|
977
984
|
if (!clientCode) {
|
|
978
985
|
clientCode = [
|
|
979
|
-
await fs__default.promises.readFile(
|
|
986
|
+
await fs__default.promises.readFile(pathe.resolve(_dirname, "client.mjs"), "utf-8"),
|
|
980
987
|
`import('${MOCK_CLASSES_MODULE_ID}')`,
|
|
981
988
|
`import('${DEVTOOLS_CSS_PATH}')`
|
|
982
989
|
].join("\n").replace("__POST_PATH__", (config.server?.origin ?? "") + POST_PATH);
|
package/dist/index.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ interface VitePluginConfig<Theme extends {} = {}> extends UserConfig<Theme> {
|
|
|
31
31
|
transformCSS?: boolean | 'pre' | 'post';
|
|
32
32
|
/**
|
|
33
33
|
*
|
|
34
|
-
* make the
|
|
34
|
+
* make the generated css processed by postcss (https://vitejs.dev/guide/features.html#postcss)
|
|
35
35
|
* @default true
|
|
36
36
|
*/
|
|
37
37
|
postcss?: boolean;
|
package/dist/index.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { createFilter } from '@rollup/pluginutils';
|
|
|
4
4
|
import { loadConfig } from '@unocss/config';
|
|
5
5
|
import { createHash } from 'crypto';
|
|
6
6
|
import MagicString from 'magic-string';
|
|
7
|
-
import { resolve, dirname } from '
|
|
7
|
+
import { resolve, dirname } from 'pathe';
|
|
8
8
|
import remapping from '@ampproject/remapping';
|
|
9
9
|
import fs from 'fs';
|
|
10
10
|
import { fileURLToPath } from 'url';
|
|
@@ -311,7 +311,8 @@ function GlobalModeBuildPlugin({ uno, ready, extract, tokens, filter, getConfig
|
|
|
311
311
|
const fakeCssId = `${chunk.fileName}-unocss-hash.css`;
|
|
312
312
|
css = await applyCssTransform(css, fakeCssId, options.dir);
|
|
313
313
|
const hash = getHash(css);
|
|
314
|
-
|
|
314
|
+
const transformHandler = "handler" in cssPost.transform ? cssPost.transform.handler : cssPost.transform;
|
|
315
|
+
await transformHandler.call({}, getHashPlaceholder(hash), fakeCssId);
|
|
315
316
|
chunk.modules[fakeCssId] = {
|
|
316
317
|
code: null,
|
|
317
318
|
originalLength: 0,
|
|
@@ -452,8 +453,14 @@ function GlobalModeDevPlugin({ uno, tokens, affectedModules, onInvalidate, extra
|
|
|
452
453
|
async configureServer(_server) {
|
|
453
454
|
servers.push(_server);
|
|
454
455
|
_server.ws.on(WS_EVENT_PREFIX, ([layer, hash]) => {
|
|
455
|
-
if (lastServedHash.get(layer) !== hash)
|
|
456
|
+
if (lastServedHash.get(layer) !== hash) {
|
|
456
457
|
sendUpdate(entries);
|
|
458
|
+
} else {
|
|
459
|
+
setTimeout(() => {
|
|
460
|
+
if (lastServedHash.get(layer) !== hash)
|
|
461
|
+
sendUpdate(entries);
|
|
462
|
+
}, 50);
|
|
463
|
+
}
|
|
457
464
|
});
|
|
458
465
|
},
|
|
459
466
|
buildStart() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unocss/vite",
|
|
3
|
-
"version": "0.45.
|
|
3
|
+
"version": "0.45.23",
|
|
4
4
|
"description": "The Vite plugin for UnoCSS",
|
|
5
5
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -44,16 +44,17 @@
|
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@ampproject/remapping": "^2.2.0",
|
|
46
46
|
"@rollup/pluginutils": "^4.2.1",
|
|
47
|
-
"@unocss/config": "0.45.
|
|
48
|
-
"@unocss/core": "0.45.
|
|
49
|
-
"@unocss/inspector": "0.45.
|
|
50
|
-
"@unocss/scope": "0.45.
|
|
51
|
-
"@unocss/transformer-directives": "0.45.
|
|
52
|
-
"magic-string": "^0.26.3"
|
|
47
|
+
"@unocss/config": "0.45.23",
|
|
48
|
+
"@unocss/core": "0.45.23",
|
|
49
|
+
"@unocss/inspector": "0.45.23",
|
|
50
|
+
"@unocss/scope": "0.45.23",
|
|
51
|
+
"@unocss/transformer-directives": "0.45.23",
|
|
52
|
+
"magic-string": "^0.26.3",
|
|
53
|
+
"pathe": "^0.3.7"
|
|
53
54
|
},
|
|
54
55
|
"devDependencies": {
|
|
55
|
-
"@unocss/shared-integration": "0.45.
|
|
56
|
-
"vite": "^3.1.
|
|
56
|
+
"@unocss/shared-integration": "0.45.23",
|
|
57
|
+
"vite": "^3.1.2"
|
|
57
58
|
},
|
|
58
59
|
"scripts": {
|
|
59
60
|
"build": "unbuild",
|