@unocss/vite 0.44.7 → 0.45.4
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/client.cjs +5 -1
- package/dist/client.mjs +5 -1
- package/dist/index.cjs +36 -14
- package/dist/index.mjs +36 -14
- package/package.json +8 -8
package/dist/client.cjs
CHANGED
|
@@ -13,7 +13,11 @@ function include(set, v) {
|
|
|
13
13
|
for (const i of v)
|
|
14
14
|
set.add(i);
|
|
15
15
|
}
|
|
16
|
-
console.log(
|
|
16
|
+
console.log(
|
|
17
|
+
"%c[unocss] devtools support enabled %c\nread more at https://windicss.org",
|
|
18
|
+
"background:#0ea5e9; color:white; padding: 1px 4px; border-radius: 3px;",
|
|
19
|
+
""
|
|
20
|
+
);
|
|
17
21
|
const visitedClasses = /* @__PURE__ */ new Set();
|
|
18
22
|
const pendingClasses = /* @__PURE__ */ new Set();
|
|
19
23
|
let _timer;
|
package/dist/client.mjs
CHANGED
|
@@ -11,7 +11,11 @@ function include(set, v) {
|
|
|
11
11
|
for (const i of v)
|
|
12
12
|
set.add(i);
|
|
13
13
|
}
|
|
14
|
-
console.log(
|
|
14
|
+
console.log(
|
|
15
|
+
"%c[unocss] devtools support enabled %c\nread more at https://windicss.org",
|
|
16
|
+
"background:#0ea5e9; color:white; padding: 1px 4px; border-radius: 3px;",
|
|
17
|
+
""
|
|
18
|
+
);
|
|
15
19
|
const visitedClasses = /* @__PURE__ */ new Set();
|
|
16
20
|
const pendingClasses = /* @__PURE__ */ new Set();
|
|
17
21
|
let _timer;
|
package/dist/index.cjs
CHANGED
|
@@ -3,15 +3,15 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const UnocssInspector = require('@unocss/inspector');
|
|
6
|
-
const path = require('path');
|
|
7
|
-
const crypto = require('crypto');
|
|
8
6
|
const core = require('@unocss/core');
|
|
9
7
|
const pluginutils = require('@rollup/pluginutils');
|
|
8
|
+
const config = require('@unocss/config');
|
|
9
|
+
const crypto = require('crypto');
|
|
10
|
+
const path = require('path');
|
|
10
11
|
const MagicString = require('magic-string');
|
|
11
12
|
const remapping = require('@ampproject/remapping');
|
|
12
13
|
const fs = require('fs');
|
|
13
14
|
const url = require('url');
|
|
14
|
-
const config = require('@unocss/config');
|
|
15
15
|
|
|
16
16
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
|
|
17
17
|
|
|
@@ -72,7 +72,10 @@ function createContext(configOrPath, defaults = {}, extraConfigSources = [], res
|
|
|
72
72
|
rawConfig = result.config;
|
|
73
73
|
uno.setConfig(rawConfig);
|
|
74
74
|
uno.config.envMode = "dev";
|
|
75
|
-
rollupFilter = pluginutils.createFilter(
|
|
75
|
+
rollupFilter = pluginutils.createFilter(
|
|
76
|
+
rawConfig.include || defaultInclude,
|
|
77
|
+
rawConfig.exclude || defaultExclude
|
|
78
|
+
);
|
|
76
79
|
tokens.clear();
|
|
77
80
|
await Promise.all(modules.map((code, id) => uno.applyExtractors(code, id, tokens)));
|
|
78
81
|
invalidate();
|
|
@@ -164,7 +167,9 @@ function replaceAsync(string, searchValue, replacer) {
|
|
|
164
167
|
});
|
|
165
168
|
});
|
|
166
169
|
} else {
|
|
167
|
-
return Promise.resolve(
|
|
170
|
+
return Promise.resolve(
|
|
171
|
+
String.prototype.replace.call(string, searchValue, replacer)
|
|
172
|
+
);
|
|
168
173
|
}
|
|
169
174
|
} catch (error) {
|
|
170
175
|
return Promise.reject(error);
|
|
@@ -449,8 +454,8 @@ function GlobalModeDevPlugin({ uno, tokens, affectedModules, onInvalidate, extra
|
|
|
449
454
|
invalidate(0);
|
|
450
455
|
});
|
|
451
456
|
},
|
|
452
|
-
|
|
453
|
-
|
|
457
|
+
buildStart() {
|
|
458
|
+
uno.generate("", { preflights: true });
|
|
454
459
|
},
|
|
455
460
|
transform(code, id) {
|
|
456
461
|
if (filter(code, id))
|
|
@@ -491,9 +496,13 @@ function GlobalModeDevPlugin({ uno, tokens, affectedModules, onInvalidate, extra
|
|
|
491
496
|
enforce: "post",
|
|
492
497
|
transform(code, id) {
|
|
493
498
|
if (entries.has(getPath(id)) && code.includes("import.meta.hot")) {
|
|
494
|
-
|
|
495
|
-
if (import.meta.hot) {
|
|
496
|
-
|
|
499
|
+
return `${code}
|
|
500
|
+
if (import.meta.hot) {
|
|
501
|
+
try { await import.meta.hot.send('${WS_EVENT_PREFIX}', ${lastServed}); }
|
|
502
|
+
catch (e) { console.warn('[unocss-hmr]', e) }
|
|
503
|
+
if (!import.meta.url.includes('?'))
|
|
504
|
+
await new Promise(resolve => setTimeout(resolve, 100))
|
|
505
|
+
}`;
|
|
497
506
|
}
|
|
498
507
|
}
|
|
499
508
|
}
|
|
@@ -607,7 +616,10 @@ function VueScopedPlugin({ uno, ready }) {
|
|
|
607
616
|
enforce: "pre",
|
|
608
617
|
async configResolved() {
|
|
609
618
|
const { config } = await ready;
|
|
610
|
-
filter = pluginutils.createFilter(
|
|
619
|
+
filter = pluginutils.createFilter(
|
|
620
|
+
config.include || [/\.vue$/],
|
|
621
|
+
config.exclude || defaultExclude
|
|
622
|
+
);
|
|
611
623
|
},
|
|
612
624
|
transform(code, id) {
|
|
613
625
|
if (!filter(id))
|
|
@@ -642,7 +654,10 @@ function SvelteScopedPlugin({ uno, ready }) {
|
|
|
642
654
|
enforce: "pre",
|
|
643
655
|
async configResolved() {
|
|
644
656
|
const { config } = await ready;
|
|
645
|
-
filter = pluginutils.createFilter(
|
|
657
|
+
filter = pluginutils.createFilter(
|
|
658
|
+
config.include || [/\.svelte$/],
|
|
659
|
+
config.exclude || defaultExclude
|
|
660
|
+
);
|
|
646
661
|
},
|
|
647
662
|
transform(code, id) {
|
|
648
663
|
if (!filter(id))
|
|
@@ -716,7 +731,11 @@ function ShadowDomModuleModePlugin({ uno }) {
|
|
|
716
731
|
const partsToApply = /* @__PURE__ */ new Map();
|
|
717
732
|
const { idxResolver, incrementIdx } = idxMapFactory();
|
|
718
733
|
while (element = nameRegexp.exec(useCode)) {
|
|
719
|
-
const result = checkElement(
|
|
734
|
+
const result = checkElement(
|
|
735
|
+
useParts,
|
|
736
|
+
idxResolver,
|
|
737
|
+
element
|
|
738
|
+
);
|
|
720
739
|
if (result) {
|
|
721
740
|
result.entries.forEach(([name, replacement]) => {
|
|
722
741
|
let list = partsToApply.get(name);
|
|
@@ -982,7 +1001,10 @@ function UnocssPlugin(configOrPath, defaults = {}) {
|
|
|
982
1001
|
} else if (mode === "global") {
|
|
983
1002
|
plugins.push(...GlobalModePlugin(ctx));
|
|
984
1003
|
} else if (mode === "dist-chunk") {
|
|
985
|
-
plugins.push(
|
|
1004
|
+
plugins.push(
|
|
1005
|
+
ChunkModeBuildPlugin(ctx),
|
|
1006
|
+
...GlobalModeDevPlugin(ctx)
|
|
1007
|
+
);
|
|
986
1008
|
} else {
|
|
987
1009
|
throw new Error(`[unocss] unknown mode "${mode}"`);
|
|
988
1010
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import UnocssInspector from '@unocss/inspector';
|
|
2
|
-
import { resolve, dirname } from 'path';
|
|
3
|
-
import { createHash } from 'crypto';
|
|
4
2
|
import { cssIdRE, createGenerator, BetterMap, notNull, toEscapedSelector } from '@unocss/core';
|
|
5
3
|
import { createFilter } from '@rollup/pluginutils';
|
|
4
|
+
import { loadConfig } from '@unocss/config';
|
|
5
|
+
import { createHash } from 'crypto';
|
|
6
|
+
import { resolve, dirname } from 'path';
|
|
6
7
|
import MagicString from 'magic-string';
|
|
7
8
|
import remapping from '@ampproject/remapping';
|
|
8
9
|
import fs from 'fs';
|
|
9
10
|
import { fileURLToPath } from 'url';
|
|
10
|
-
import { loadConfig } from '@unocss/config';
|
|
11
11
|
|
|
12
12
|
const defaultExclude = [cssIdRE];
|
|
13
13
|
const defaultInclude = [/\.vue$/, /\.vue\?vue/, /\.svelte$/, /\.[jt]sx$/, /\.mdx?$/, /\.astro$/, /\.elm$/, /\.html$/];
|
|
@@ -61,7 +61,10 @@ function createContext(configOrPath, defaults = {}, extraConfigSources = [], res
|
|
|
61
61
|
rawConfig = result.config;
|
|
62
62
|
uno.setConfig(rawConfig);
|
|
63
63
|
uno.config.envMode = "dev";
|
|
64
|
-
rollupFilter = createFilter(
|
|
64
|
+
rollupFilter = createFilter(
|
|
65
|
+
rawConfig.include || defaultInclude,
|
|
66
|
+
rawConfig.exclude || defaultExclude
|
|
67
|
+
);
|
|
65
68
|
tokens.clear();
|
|
66
69
|
await Promise.all(modules.map((code, id) => uno.applyExtractors(code, id, tokens)));
|
|
67
70
|
invalidate();
|
|
@@ -153,7 +156,9 @@ function replaceAsync(string, searchValue, replacer) {
|
|
|
153
156
|
});
|
|
154
157
|
});
|
|
155
158
|
} else {
|
|
156
|
-
return Promise.resolve(
|
|
159
|
+
return Promise.resolve(
|
|
160
|
+
String.prototype.replace.call(string, searchValue, replacer)
|
|
161
|
+
);
|
|
157
162
|
}
|
|
158
163
|
} catch (error) {
|
|
159
164
|
return Promise.reject(error);
|
|
@@ -438,8 +443,8 @@ function GlobalModeDevPlugin({ uno, tokens, affectedModules, onInvalidate, extra
|
|
|
438
443
|
invalidate(0);
|
|
439
444
|
});
|
|
440
445
|
},
|
|
441
|
-
|
|
442
|
-
|
|
446
|
+
buildStart() {
|
|
447
|
+
uno.generate("", { preflights: true });
|
|
443
448
|
},
|
|
444
449
|
transform(code, id) {
|
|
445
450
|
if (filter(code, id))
|
|
@@ -480,9 +485,13 @@ function GlobalModeDevPlugin({ uno, tokens, affectedModules, onInvalidate, extra
|
|
|
480
485
|
enforce: "post",
|
|
481
486
|
transform(code, id) {
|
|
482
487
|
if (entries.has(getPath(id)) && code.includes("import.meta.hot")) {
|
|
483
|
-
|
|
484
|
-
if (import.meta.hot) {
|
|
485
|
-
|
|
488
|
+
return `${code}
|
|
489
|
+
if (import.meta.hot) {
|
|
490
|
+
try { await import.meta.hot.send('${WS_EVENT_PREFIX}', ${lastServed}); }
|
|
491
|
+
catch (e) { console.warn('[unocss-hmr]', e) }
|
|
492
|
+
if (!import.meta.url.includes('?'))
|
|
493
|
+
await new Promise(resolve => setTimeout(resolve, 100))
|
|
494
|
+
}`;
|
|
486
495
|
}
|
|
487
496
|
}
|
|
488
497
|
}
|
|
@@ -596,7 +605,10 @@ function VueScopedPlugin({ uno, ready }) {
|
|
|
596
605
|
enforce: "pre",
|
|
597
606
|
async configResolved() {
|
|
598
607
|
const { config } = await ready;
|
|
599
|
-
filter = createFilter(
|
|
608
|
+
filter = createFilter(
|
|
609
|
+
config.include || [/\.vue$/],
|
|
610
|
+
config.exclude || defaultExclude
|
|
611
|
+
);
|
|
600
612
|
},
|
|
601
613
|
transform(code, id) {
|
|
602
614
|
if (!filter(id))
|
|
@@ -631,7 +643,10 @@ function SvelteScopedPlugin({ uno, ready }) {
|
|
|
631
643
|
enforce: "pre",
|
|
632
644
|
async configResolved() {
|
|
633
645
|
const { config } = await ready;
|
|
634
|
-
filter = createFilter(
|
|
646
|
+
filter = createFilter(
|
|
647
|
+
config.include || [/\.svelte$/],
|
|
648
|
+
config.exclude || defaultExclude
|
|
649
|
+
);
|
|
635
650
|
},
|
|
636
651
|
transform(code, id) {
|
|
637
652
|
if (!filter(id))
|
|
@@ -705,7 +720,11 @@ function ShadowDomModuleModePlugin({ uno }) {
|
|
|
705
720
|
const partsToApply = /* @__PURE__ */ new Map();
|
|
706
721
|
const { idxResolver, incrementIdx } = idxMapFactory();
|
|
707
722
|
while (element = nameRegexp.exec(useCode)) {
|
|
708
|
-
const result = checkElement(
|
|
723
|
+
const result = checkElement(
|
|
724
|
+
useParts,
|
|
725
|
+
idxResolver,
|
|
726
|
+
element
|
|
727
|
+
);
|
|
709
728
|
if (result) {
|
|
710
729
|
result.entries.forEach(([name, replacement]) => {
|
|
711
730
|
let list = partsToApply.get(name);
|
|
@@ -971,7 +990,10 @@ function UnocssPlugin(configOrPath, defaults = {}) {
|
|
|
971
990
|
} else if (mode === "global") {
|
|
972
991
|
plugins.push(...GlobalModePlugin(ctx));
|
|
973
992
|
} else if (mode === "dist-chunk") {
|
|
974
|
-
plugins.push(
|
|
993
|
+
plugins.push(
|
|
994
|
+
ChunkModeBuildPlugin(ctx),
|
|
995
|
+
...GlobalModeDevPlugin(ctx)
|
|
996
|
+
);
|
|
975
997
|
} else {
|
|
976
998
|
throw new Error(`[unocss] unknown mode "${mode}"`);
|
|
977
999
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unocss/vite",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.45.4",
|
|
4
4
|
"description": "The Vite plugin for UnoCSS",
|
|
5
5
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -44,16 +44,16 @@
|
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@ampproject/remapping": "^2.2.0",
|
|
46
46
|
"@rollup/pluginutils": "^4.2.1",
|
|
47
|
-
"@unocss/config": "0.
|
|
48
|
-
"@unocss/core": "0.
|
|
49
|
-
"@unocss/inspector": "0.
|
|
50
|
-
"@unocss/scope": "0.
|
|
51
|
-
"@unocss/transformer-directives": "0.
|
|
47
|
+
"@unocss/config": "0.45.4",
|
|
48
|
+
"@unocss/core": "0.45.4",
|
|
49
|
+
"@unocss/inspector": "0.45.4",
|
|
50
|
+
"@unocss/scope": "0.45.4",
|
|
51
|
+
"@unocss/transformer-directives": "0.45.4",
|
|
52
52
|
"magic-string": "^0.26.2"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@unocss/shared-integration": "0.
|
|
56
|
-
"vite": "^
|
|
55
|
+
"@unocss/shared-integration": "0.45.4",
|
|
56
|
+
"vite": "^3.0.4"
|
|
57
57
|
},
|
|
58
58
|
"scripts": {
|
|
59
59
|
"build": "unbuild",
|