@unocss/vite 0.14.2 → 0.15.2
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.js → index.cjs} +50 -96
- package/dist/index.mjs +29 -56
- package/package.json +9 -9
|
@@ -1,49 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
for (var name in all)
|
|
11
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
-
};
|
|
13
|
-
var __reExport = (target, module2, desc) => {
|
|
14
|
-
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
15
|
-
for (let key of __getOwnPropNames(module2))
|
|
16
|
-
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
17
|
-
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
18
|
-
}
|
|
19
|
-
return target;
|
|
20
|
-
};
|
|
21
|
-
var __toModule = (module2) => {
|
|
22
|
-
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
23
|
-
};
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const UnocssInspector = require('@unocss/inspector');
|
|
6
|
+
const pluginutils = require('@rollup/pluginutils');
|
|
7
|
+
const config = require('@unocss/config');
|
|
8
|
+
const core = require('@unocss/core');
|
|
9
|
+
const crypto = require('crypto');
|
|
24
10
|
|
|
25
|
-
|
|
26
|
-
__export(exports, {
|
|
27
|
-
ChunkModeBuildPlugin: () => ChunkModeBuildPlugin,
|
|
28
|
-
GlobalModeBuildPlugin: () => GlobalModeBuildPlugin,
|
|
29
|
-
GlobalModeDevPlugin: () => GlobalModeDevPlugin,
|
|
30
|
-
GlobalModePlugin: () => GlobalModePlugin,
|
|
31
|
-
PerModuleModePlugin: () => PerModuleModePlugin,
|
|
32
|
-
VueScopedPlugin: () => VueScopedPlugin,
|
|
33
|
-
default: () => UnocssPlugin,
|
|
34
|
-
defineConfig: () => defineConfig
|
|
35
|
-
});
|
|
36
|
-
var import_inspector = __toModule(require("@unocss/inspector"));
|
|
11
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
|
|
37
12
|
|
|
38
|
-
|
|
39
|
-
var defaultExclude = [/\.(css|postcss|sass|scss|less|stylus|styl)$/];
|
|
40
|
-
var defaultInclude = [/\.vue$/, /\.vue\?vue/, /\.svelte$/, /\.[jt]sx$/, /\.mdx?$/, /\.astro$/];
|
|
13
|
+
const UnocssInspector__default = /*#__PURE__*/_interopDefaultLegacy(UnocssInspector);
|
|
41
14
|
|
|
42
|
-
|
|
43
|
-
|
|
15
|
+
const defaultExclude = [/\.(css|postcss|sass|scss|less|stylus|styl)$/];
|
|
16
|
+
const defaultInclude = [/\.vue$/, /\.vue\?vue/, /\.svelte$/, /\.[jt]sx$/, /\.mdx?$/, /\.astro$/];
|
|
17
|
+
|
|
18
|
+
const VIRTUAL_ENTRY_ALIAS = [
|
|
44
19
|
/^(?:virtual:)?uno(?::(.+))?\.css(\?.*)?$/
|
|
45
20
|
];
|
|
46
|
-
|
|
21
|
+
const LAYER_MARK_ALL = "__ALL__";
|
|
47
22
|
function resolveId(id) {
|
|
48
23
|
for (const alias of VIRTUAL_ENTRY_ALIAS) {
|
|
49
24
|
const match = id.match(alias);
|
|
@@ -58,37 +33,32 @@ function resolveId(id) {
|
|
|
58
33
|
}
|
|
59
34
|
}
|
|
60
35
|
}
|
|
61
|
-
|
|
36
|
+
const LAYER_PLACEHOLDER_RE = /(\\?")?#--unocss--\s*{\s*layer\s*:\s*(.+?);?\s*}/g;
|
|
62
37
|
function getLayerPlaceholder(layer) {
|
|
63
38
|
return `#--unocss--{layer:${layer}}`;
|
|
64
39
|
}
|
|
65
|
-
|
|
40
|
+
const HASH_PLACEHOLDER_RE = /#--unocss-hash--\s*{\s*content\s*:\s*"(.+?)";?\s*}/g;
|
|
66
41
|
function getHashPlaceholder(hash) {
|
|
67
42
|
return `#--unocss-hash--{content:"${hash}"}`;
|
|
68
43
|
}
|
|
69
44
|
|
|
70
|
-
|
|
71
|
-
var INCLUDE_COMMENT = "@unocss-include";
|
|
45
|
+
const INCLUDE_COMMENT = "@unocss-include";
|
|
72
46
|
|
|
73
|
-
// ../plugins-common/context.ts
|
|
74
|
-
var import_pluginutils = __toModule(require("@rollup/pluginutils"));
|
|
75
|
-
var import_config = __toModule(require("@unocss/config"));
|
|
76
|
-
var import_core = __toModule(require("@unocss/core"));
|
|
77
47
|
function createContext(configOrPath, defaults = {}, extraConfigSources = []) {
|
|
78
|
-
const loadConfig =
|
|
48
|
+
const loadConfig = config.createConfigLoader(configOrPath, extraConfigSources);
|
|
79
49
|
let rawConfig = {};
|
|
80
|
-
const uno =
|
|
81
|
-
let rollupFilter =
|
|
50
|
+
const uno = core.createGenerator(rawConfig, defaults);
|
|
51
|
+
let rollupFilter = pluginutils.createFilter(defaultInclude, defaultExclude);
|
|
82
52
|
const invalidations = [];
|
|
83
|
-
const modules = new
|
|
84
|
-
const tokens = new Set();
|
|
53
|
+
const modules = new core.BetterMap();
|
|
54
|
+
const tokens = /* @__PURE__ */ new Set();
|
|
85
55
|
const ready = reloadConfig();
|
|
86
56
|
async function reloadConfig() {
|
|
87
57
|
const result = await loadConfig();
|
|
88
58
|
rawConfig = result.config;
|
|
89
59
|
uno.setConfig(rawConfig);
|
|
90
60
|
uno.config.envMode = "dev";
|
|
91
|
-
rollupFilter =
|
|
61
|
+
rollupFilter = pluginutils.createFilter(rawConfig.include || defaultInclude, rawConfig.exclude || defaultExclude);
|
|
92
62
|
tokens.clear();
|
|
93
63
|
await Promise.all(modules.map((code, id) => uno.applyExtractors(code, id, tokens)));
|
|
94
64
|
invalidate();
|
|
@@ -128,16 +98,13 @@ function createContext(configOrPath, defaults = {}, extraConfigSources = []) {
|
|
|
128
98
|
};
|
|
129
99
|
}
|
|
130
100
|
|
|
131
|
-
// ../plugins-common/utils.ts
|
|
132
|
-
var import_crypto = __toModule(require("crypto"));
|
|
133
101
|
function getHash(input, length = 8) {
|
|
134
|
-
return
|
|
102
|
+
return crypto.createHash("sha256").update(input).digest("hex").slice(0, length);
|
|
135
103
|
}
|
|
136
104
|
function getPath(id) {
|
|
137
105
|
return id.replace(/\?.*$/, "");
|
|
138
106
|
}
|
|
139
107
|
|
|
140
|
-
// src/modes/chunk-build.ts
|
|
141
108
|
function ChunkModeBuildPlugin({ uno, filter }) {
|
|
142
109
|
let cssPlugin;
|
|
143
110
|
const files = {};
|
|
@@ -158,7 +125,7 @@ function ChunkModeBuildPlugin({ uno, filter }) {
|
|
|
158
125
|
const chunks = Object.keys(chunk.modules).map((i) => files[i]).filter(Boolean);
|
|
159
126
|
if (!chunks.length)
|
|
160
127
|
return null;
|
|
161
|
-
const tokens = new Set();
|
|
128
|
+
const tokens = /* @__PURE__ */ new Set();
|
|
162
129
|
await Promise.all(chunks.map((c) => uno.applyExtractors(c, void 0, tokens)));
|
|
163
130
|
const { css } = await uno.generate(tokens);
|
|
164
131
|
const fakeCssId = `${chunk.fileName}.css`;
|
|
@@ -180,9 +147,8 @@ function ChunkModeBuildPlugin({ uno, filter }) {
|
|
|
180
147
|
};
|
|
181
148
|
}
|
|
182
149
|
|
|
183
|
-
// src/modes/global/build.ts
|
|
184
150
|
function GlobalModeBuildPlugin({ uno, ready, extract, tokens, modules, filter }) {
|
|
185
|
-
const vfsLayerMap = new Map();
|
|
151
|
+
const vfsLayerMap = /* @__PURE__ */ new Map();
|
|
186
152
|
let tasks = [];
|
|
187
153
|
let cssPlugin;
|
|
188
154
|
return [
|
|
@@ -227,7 +193,7 @@ function GlobalModeBuildPlugin({ uno, ready, extract, tokens, modules, filter })
|
|
|
227
193
|
const chunks = Object.keys(chunk.modules).filter((i) => modules.has(i));
|
|
228
194
|
if (!chunks.length)
|
|
229
195
|
return null;
|
|
230
|
-
const tokens2 = new Set();
|
|
196
|
+
const tokens2 = /* @__PURE__ */ new Set();
|
|
231
197
|
await Promise.all(chunks.map((c) => uno.applyExtractors(modules.get(c) || "", c, tokens2)));
|
|
232
198
|
const { css } = await uno.generate(tokens2, { minify: true });
|
|
233
199
|
if (!css)
|
|
@@ -248,8 +214,7 @@ function GlobalModeBuildPlugin({ uno, ready, extract, tokens, modules, filter })
|
|
|
248
214
|
{
|
|
249
215
|
name: "unocss:global:build:generate",
|
|
250
216
|
apply(options, { command }) {
|
|
251
|
-
|
|
252
|
-
return command === "build" && !((_a = options.build) == null ? void 0 : _a.ssr);
|
|
217
|
+
return command === "build" && !options.build?.ssr;
|
|
253
218
|
},
|
|
254
219
|
enforce: "post",
|
|
255
220
|
async generateBundle(_, bundle) {
|
|
@@ -276,15 +241,13 @@ function GlobalModeBuildPlugin({ uno, ready, extract, tokens, modules, filter })
|
|
|
276
241
|
];
|
|
277
242
|
}
|
|
278
243
|
|
|
279
|
-
|
|
280
|
-
var READY_CALLBACK_DEFAULT = "/__unocss_ready";
|
|
244
|
+
const READY_CALLBACK_DEFAULT = "/__unocss_ready";
|
|
281
245
|
|
|
282
|
-
|
|
283
|
-
var WARN_TIMEOUT = 2e3;
|
|
246
|
+
const WARN_TIMEOUT = 2e3;
|
|
284
247
|
function GlobalModeDevPlugin({ uno, tokens, onInvalidate, extract, filter }) {
|
|
285
248
|
const servers = [];
|
|
286
249
|
const tasks = [];
|
|
287
|
-
const entries = new Map();
|
|
250
|
+
const entries = /* @__PURE__ */ new Map();
|
|
288
251
|
let invalidateTimer;
|
|
289
252
|
let lastUpdate = Date.now();
|
|
290
253
|
let lastServed = 0;
|
|
@@ -339,9 +302,8 @@ function GlobalModeDevPlugin({ uno, tokens, onInvalidate, extract, filter }) {
|
|
|
339
302
|
async configureServer(_server) {
|
|
340
303
|
servers.push(_server);
|
|
341
304
|
_server.middlewares.use(async (req, res, next) => {
|
|
342
|
-
var _a;
|
|
343
305
|
setWarnTimer();
|
|
344
|
-
if (
|
|
306
|
+
if (req.url?.startsWith(READY_CALLBACK_DEFAULT)) {
|
|
345
307
|
const servedTime = +req.url.slice(READY_CALLBACK_DEFAULT.length + 1);
|
|
346
308
|
if (servedTime < lastUpdate)
|
|
347
309
|
invalidate(0);
|
|
@@ -384,8 +346,7 @@ function GlobalModeDevPlugin({ uno, tokens, onInvalidate, extract, filter }) {
|
|
|
384
346
|
{
|
|
385
347
|
name: "unocss:global:post",
|
|
386
348
|
apply(config, env) {
|
|
387
|
-
|
|
388
|
-
return env.command === "serve" && !((_a = config.build) == null ? void 0 : _a.ssr);
|
|
349
|
+
return env.command === "serve" && !config.build?.ssr;
|
|
389
350
|
},
|
|
390
351
|
enforce: "post",
|
|
391
352
|
transform(code, id) {
|
|
@@ -397,7 +358,6 @@ await fetch("${READY_CALLBACK_DEFAULT}/${lastServed}")`;
|
|
|
397
358
|
];
|
|
398
359
|
}
|
|
399
360
|
|
|
400
|
-
// src/modes/global/index.ts
|
|
401
361
|
function GlobalModePlugin(ctx) {
|
|
402
362
|
return [
|
|
403
363
|
...GlobalModeBuildPlugin(ctx),
|
|
@@ -405,11 +365,10 @@ function GlobalModePlugin(ctx) {
|
|
|
405
365
|
];
|
|
406
366
|
}
|
|
407
367
|
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
var SCOPE_IMPORT_RE = / from (['"])(@unocss\/scope)\1/;
|
|
368
|
+
const VIRTUAL_PREFIX = "/@unocss/";
|
|
369
|
+
const SCOPE_IMPORT_RE = / from (['"])(@unocss\/scope)\1/;
|
|
411
370
|
function PerModuleModePlugin({ uno, filter }) {
|
|
412
|
-
const moduleMap = new Map();
|
|
371
|
+
const moduleMap = /* @__PURE__ */ new Map();
|
|
413
372
|
let server;
|
|
414
373
|
const invalidate = (hash) => {
|
|
415
374
|
if (!server)
|
|
@@ -469,10 +428,8 @@ ${css}`;
|
|
|
469
428
|
};
|
|
470
429
|
}
|
|
471
430
|
|
|
472
|
-
// src/modes/vue-scoped.ts
|
|
473
|
-
var import_pluginutils2 = __toModule(require("@rollup/pluginutils"));
|
|
474
431
|
function VueScopedPlugin({ uno, ready }) {
|
|
475
|
-
let filter =
|
|
432
|
+
let filter = pluginutils.createFilter([/\.vue$/], defaultExclude);
|
|
476
433
|
async function transformSFC(code) {
|
|
477
434
|
const { css } = await uno.generate(code);
|
|
478
435
|
if (!css)
|
|
@@ -485,7 +442,7 @@ function VueScopedPlugin({ uno, ready }) {
|
|
|
485
442
|
enforce: "pre",
|
|
486
443
|
async configResolved() {
|
|
487
444
|
const { config } = await ready;
|
|
488
|
-
filter =
|
|
445
|
+
filter = pluginutils.createFilter(config.include || [/\.vue$/], config.exclude || defaultExclude);
|
|
489
446
|
},
|
|
490
447
|
transform(code, id) {
|
|
491
448
|
if (!filter(id))
|
|
@@ -504,7 +461,6 @@ function VueScopedPlugin({ uno, ready }) {
|
|
|
504
461
|
};
|
|
505
462
|
}
|
|
506
463
|
|
|
507
|
-
// src/config-hmr.ts
|
|
508
464
|
function ConfigHMRPlugin(ctx) {
|
|
509
465
|
const { ready, uno } = ctx;
|
|
510
466
|
return {
|
|
@@ -531,7 +487,6 @@ function ConfigHMRPlugin(ctx) {
|
|
|
531
487
|
};
|
|
532
488
|
}
|
|
533
489
|
|
|
534
|
-
// src/index.ts
|
|
535
490
|
function defineConfig(config) {
|
|
536
491
|
return config;
|
|
537
492
|
}
|
|
@@ -543,7 +498,7 @@ function UnocssPlugin(configOrPath, defaults = {}) {
|
|
|
543
498
|
ConfigHMRPlugin(ctx)
|
|
544
499
|
];
|
|
545
500
|
if (inlineConfig.inspector !== false)
|
|
546
|
-
plugins.push((
|
|
501
|
+
plugins.push(UnocssInspector__default(ctx));
|
|
547
502
|
if (mode === "per-module") {
|
|
548
503
|
plugins.push(PerModuleModePlugin(ctx));
|
|
549
504
|
} else if (mode === "vue-scoped") {
|
|
@@ -557,13 +512,12 @@ function UnocssPlugin(configOrPath, defaults = {}) {
|
|
|
557
512
|
}
|
|
558
513
|
return plugins.filter(Boolean);
|
|
559
514
|
}
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
});
|
|
515
|
+
|
|
516
|
+
exports.ChunkModeBuildPlugin = ChunkModeBuildPlugin;
|
|
517
|
+
exports.GlobalModeBuildPlugin = GlobalModeBuildPlugin;
|
|
518
|
+
exports.GlobalModeDevPlugin = GlobalModeDevPlugin;
|
|
519
|
+
exports.GlobalModePlugin = GlobalModePlugin;
|
|
520
|
+
exports.PerModuleModePlugin = PerModuleModePlugin;
|
|
521
|
+
exports.VueScopedPlugin = VueScopedPlugin;
|
|
522
|
+
exports["default"] = UnocssPlugin;
|
|
523
|
+
exports.defineConfig = defineConfig;
|
package/dist/index.mjs
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
1
|
+
import UnocssInspector from '@unocss/inspector';
|
|
2
|
+
import { createFilter } from '@rollup/pluginutils';
|
|
3
|
+
import { createConfigLoader } from '@unocss/config';
|
|
4
|
+
import { createGenerator, BetterMap } from '@unocss/core';
|
|
5
|
+
import { createHash } from 'crypto';
|
|
3
6
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var defaultInclude = [/\.vue$/, /\.vue\?vue/, /\.svelte$/, /\.[jt]sx$/, /\.mdx?$/, /\.astro$/];
|
|
7
|
+
const defaultExclude = [/\.(css|postcss|sass|scss|less|stylus|styl)$/];
|
|
8
|
+
const defaultInclude = [/\.vue$/, /\.vue\?vue/, /\.svelte$/, /\.[jt]sx$/, /\.mdx?$/, /\.astro$/];
|
|
7
9
|
|
|
8
|
-
|
|
9
|
-
var VIRTUAL_ENTRY_ALIAS = [
|
|
10
|
+
const VIRTUAL_ENTRY_ALIAS = [
|
|
10
11
|
/^(?:virtual:)?uno(?::(.+))?\.css(\?.*)?$/
|
|
11
12
|
];
|
|
12
|
-
|
|
13
|
+
const LAYER_MARK_ALL = "__ALL__";
|
|
13
14
|
function resolveId(id) {
|
|
14
15
|
for (const alias of VIRTUAL_ENTRY_ALIAS) {
|
|
15
16
|
const match = id.match(alias);
|
|
@@ -24,22 +25,17 @@ function resolveId(id) {
|
|
|
24
25
|
}
|
|
25
26
|
}
|
|
26
27
|
}
|
|
27
|
-
|
|
28
|
+
const LAYER_PLACEHOLDER_RE = /(\\?")?#--unocss--\s*{\s*layer\s*:\s*(.+?);?\s*}/g;
|
|
28
29
|
function getLayerPlaceholder(layer) {
|
|
29
30
|
return `#--unocss--{layer:${layer}}`;
|
|
30
31
|
}
|
|
31
|
-
|
|
32
|
+
const HASH_PLACEHOLDER_RE = /#--unocss-hash--\s*{\s*content\s*:\s*"(.+?)";?\s*}/g;
|
|
32
33
|
function getHashPlaceholder(hash) {
|
|
33
34
|
return `#--unocss-hash--{content:"${hash}"}`;
|
|
34
35
|
}
|
|
35
36
|
|
|
36
|
-
|
|
37
|
-
var INCLUDE_COMMENT = "@unocss-include";
|
|
37
|
+
const INCLUDE_COMMENT = "@unocss-include";
|
|
38
38
|
|
|
39
|
-
// ../plugins-common/context.ts
|
|
40
|
-
import { createFilter } from "@rollup/pluginutils";
|
|
41
|
-
import { createConfigLoader } from "@unocss/config";
|
|
42
|
-
import { BetterMap, createGenerator } from "@unocss/core";
|
|
43
39
|
function createContext(configOrPath, defaults = {}, extraConfigSources = []) {
|
|
44
40
|
const loadConfig = createConfigLoader(configOrPath, extraConfigSources);
|
|
45
41
|
let rawConfig = {};
|
|
@@ -47,7 +43,7 @@ function createContext(configOrPath, defaults = {}, extraConfigSources = []) {
|
|
|
47
43
|
let rollupFilter = createFilter(defaultInclude, defaultExclude);
|
|
48
44
|
const invalidations = [];
|
|
49
45
|
const modules = new BetterMap();
|
|
50
|
-
const tokens = new Set();
|
|
46
|
+
const tokens = /* @__PURE__ */ new Set();
|
|
51
47
|
const ready = reloadConfig();
|
|
52
48
|
async function reloadConfig() {
|
|
53
49
|
const result = await loadConfig();
|
|
@@ -94,8 +90,6 @@ function createContext(configOrPath, defaults = {}, extraConfigSources = []) {
|
|
|
94
90
|
};
|
|
95
91
|
}
|
|
96
92
|
|
|
97
|
-
// ../plugins-common/utils.ts
|
|
98
|
-
import { createHash } from "crypto";
|
|
99
93
|
function getHash(input, length = 8) {
|
|
100
94
|
return createHash("sha256").update(input).digest("hex").slice(0, length);
|
|
101
95
|
}
|
|
@@ -103,7 +97,6 @@ function getPath(id) {
|
|
|
103
97
|
return id.replace(/\?.*$/, "");
|
|
104
98
|
}
|
|
105
99
|
|
|
106
|
-
// src/modes/chunk-build.ts
|
|
107
100
|
function ChunkModeBuildPlugin({ uno, filter }) {
|
|
108
101
|
let cssPlugin;
|
|
109
102
|
const files = {};
|
|
@@ -124,7 +117,7 @@ function ChunkModeBuildPlugin({ uno, filter }) {
|
|
|
124
117
|
const chunks = Object.keys(chunk.modules).map((i) => files[i]).filter(Boolean);
|
|
125
118
|
if (!chunks.length)
|
|
126
119
|
return null;
|
|
127
|
-
const tokens = new Set();
|
|
120
|
+
const tokens = /* @__PURE__ */ new Set();
|
|
128
121
|
await Promise.all(chunks.map((c) => uno.applyExtractors(c, void 0, tokens)));
|
|
129
122
|
const { css } = await uno.generate(tokens);
|
|
130
123
|
const fakeCssId = `${chunk.fileName}.css`;
|
|
@@ -146,9 +139,8 @@ function ChunkModeBuildPlugin({ uno, filter }) {
|
|
|
146
139
|
};
|
|
147
140
|
}
|
|
148
141
|
|
|
149
|
-
// src/modes/global/build.ts
|
|
150
142
|
function GlobalModeBuildPlugin({ uno, ready, extract, tokens, modules, filter }) {
|
|
151
|
-
const vfsLayerMap = new Map();
|
|
143
|
+
const vfsLayerMap = /* @__PURE__ */ new Map();
|
|
152
144
|
let tasks = [];
|
|
153
145
|
let cssPlugin;
|
|
154
146
|
return [
|
|
@@ -193,7 +185,7 @@ function GlobalModeBuildPlugin({ uno, ready, extract, tokens, modules, filter })
|
|
|
193
185
|
const chunks = Object.keys(chunk.modules).filter((i) => modules.has(i));
|
|
194
186
|
if (!chunks.length)
|
|
195
187
|
return null;
|
|
196
|
-
const tokens2 = new Set();
|
|
188
|
+
const tokens2 = /* @__PURE__ */ new Set();
|
|
197
189
|
await Promise.all(chunks.map((c) => uno.applyExtractors(modules.get(c) || "", c, tokens2)));
|
|
198
190
|
const { css } = await uno.generate(tokens2, { minify: true });
|
|
199
191
|
if (!css)
|
|
@@ -214,8 +206,7 @@ function GlobalModeBuildPlugin({ uno, ready, extract, tokens, modules, filter })
|
|
|
214
206
|
{
|
|
215
207
|
name: "unocss:global:build:generate",
|
|
216
208
|
apply(options, { command }) {
|
|
217
|
-
|
|
218
|
-
return command === "build" && !((_a = options.build) == null ? void 0 : _a.ssr);
|
|
209
|
+
return command === "build" && !options.build?.ssr;
|
|
219
210
|
},
|
|
220
211
|
enforce: "post",
|
|
221
212
|
async generateBundle(_, bundle) {
|
|
@@ -242,15 +233,13 @@ function GlobalModeBuildPlugin({ uno, ready, extract, tokens, modules, filter })
|
|
|
242
233
|
];
|
|
243
234
|
}
|
|
244
235
|
|
|
245
|
-
|
|
246
|
-
var READY_CALLBACK_DEFAULT = "/__unocss_ready";
|
|
236
|
+
const READY_CALLBACK_DEFAULT = "/__unocss_ready";
|
|
247
237
|
|
|
248
|
-
|
|
249
|
-
var WARN_TIMEOUT = 2e3;
|
|
238
|
+
const WARN_TIMEOUT = 2e3;
|
|
250
239
|
function GlobalModeDevPlugin({ uno, tokens, onInvalidate, extract, filter }) {
|
|
251
240
|
const servers = [];
|
|
252
241
|
const tasks = [];
|
|
253
|
-
const entries = new Map();
|
|
242
|
+
const entries = /* @__PURE__ */ new Map();
|
|
254
243
|
let invalidateTimer;
|
|
255
244
|
let lastUpdate = Date.now();
|
|
256
245
|
let lastServed = 0;
|
|
@@ -305,9 +294,8 @@ function GlobalModeDevPlugin({ uno, tokens, onInvalidate, extract, filter }) {
|
|
|
305
294
|
async configureServer(_server) {
|
|
306
295
|
servers.push(_server);
|
|
307
296
|
_server.middlewares.use(async (req, res, next) => {
|
|
308
|
-
var _a;
|
|
309
297
|
setWarnTimer();
|
|
310
|
-
if (
|
|
298
|
+
if (req.url?.startsWith(READY_CALLBACK_DEFAULT)) {
|
|
311
299
|
const servedTime = +req.url.slice(READY_CALLBACK_DEFAULT.length + 1);
|
|
312
300
|
if (servedTime < lastUpdate)
|
|
313
301
|
invalidate(0);
|
|
@@ -350,8 +338,7 @@ function GlobalModeDevPlugin({ uno, tokens, onInvalidate, extract, filter }) {
|
|
|
350
338
|
{
|
|
351
339
|
name: "unocss:global:post",
|
|
352
340
|
apply(config, env) {
|
|
353
|
-
|
|
354
|
-
return env.command === "serve" && !((_a = config.build) == null ? void 0 : _a.ssr);
|
|
341
|
+
return env.command === "serve" && !config.build?.ssr;
|
|
355
342
|
},
|
|
356
343
|
enforce: "post",
|
|
357
344
|
transform(code, id) {
|
|
@@ -363,7 +350,6 @@ await fetch("${READY_CALLBACK_DEFAULT}/${lastServed}")`;
|
|
|
363
350
|
];
|
|
364
351
|
}
|
|
365
352
|
|
|
366
|
-
// src/modes/global/index.ts
|
|
367
353
|
function GlobalModePlugin(ctx) {
|
|
368
354
|
return [
|
|
369
355
|
...GlobalModeBuildPlugin(ctx),
|
|
@@ -371,11 +357,10 @@ function GlobalModePlugin(ctx) {
|
|
|
371
357
|
];
|
|
372
358
|
}
|
|
373
359
|
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
var SCOPE_IMPORT_RE = / from (['"])(@unocss\/scope)\1/;
|
|
360
|
+
const VIRTUAL_PREFIX = "/@unocss/";
|
|
361
|
+
const SCOPE_IMPORT_RE = / from (['"])(@unocss\/scope)\1/;
|
|
377
362
|
function PerModuleModePlugin({ uno, filter }) {
|
|
378
|
-
const moduleMap = new Map();
|
|
363
|
+
const moduleMap = /* @__PURE__ */ new Map();
|
|
379
364
|
let server;
|
|
380
365
|
const invalidate = (hash) => {
|
|
381
366
|
if (!server)
|
|
@@ -435,10 +420,8 @@ ${css}`;
|
|
|
435
420
|
};
|
|
436
421
|
}
|
|
437
422
|
|
|
438
|
-
// src/modes/vue-scoped.ts
|
|
439
|
-
import { createFilter as createFilter2 } from "@rollup/pluginutils";
|
|
440
423
|
function VueScopedPlugin({ uno, ready }) {
|
|
441
|
-
let filter =
|
|
424
|
+
let filter = createFilter([/\.vue$/], defaultExclude);
|
|
442
425
|
async function transformSFC(code) {
|
|
443
426
|
const { css } = await uno.generate(code);
|
|
444
427
|
if (!css)
|
|
@@ -451,7 +434,7 @@ function VueScopedPlugin({ uno, ready }) {
|
|
|
451
434
|
enforce: "pre",
|
|
452
435
|
async configResolved() {
|
|
453
436
|
const { config } = await ready;
|
|
454
|
-
filter =
|
|
437
|
+
filter = createFilter(config.include || [/\.vue$/], config.exclude || defaultExclude);
|
|
455
438
|
},
|
|
456
439
|
transform(code, id) {
|
|
457
440
|
if (!filter(id))
|
|
@@ -470,7 +453,6 @@ function VueScopedPlugin({ uno, ready }) {
|
|
|
470
453
|
};
|
|
471
454
|
}
|
|
472
455
|
|
|
473
|
-
// src/config-hmr.ts
|
|
474
456
|
function ConfigHMRPlugin(ctx) {
|
|
475
457
|
const { ready, uno } = ctx;
|
|
476
458
|
return {
|
|
@@ -497,7 +479,6 @@ function ConfigHMRPlugin(ctx) {
|
|
|
497
479
|
};
|
|
498
480
|
}
|
|
499
481
|
|
|
500
|
-
// src/index.ts
|
|
501
482
|
function defineConfig(config) {
|
|
502
483
|
return config;
|
|
503
484
|
}
|
|
@@ -523,13 +504,5 @@ function UnocssPlugin(configOrPath, defaults = {}) {
|
|
|
523
504
|
}
|
|
524
505
|
return plugins.filter(Boolean);
|
|
525
506
|
}
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
GlobalModeBuildPlugin,
|
|
529
|
-
GlobalModeDevPlugin,
|
|
530
|
-
GlobalModePlugin,
|
|
531
|
-
PerModuleModePlugin,
|
|
532
|
-
VueScopedPlugin,
|
|
533
|
-
UnocssPlugin as default,
|
|
534
|
-
defineConfig
|
|
535
|
-
};
|
|
507
|
+
|
|
508
|
+
export { ChunkModeBuildPlugin, GlobalModeBuildPlugin, GlobalModeDevPlugin, GlobalModePlugin, PerModuleModePlugin, VueScopedPlugin, UnocssPlugin as default, defineConfig };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unocss/vite",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.2",
|
|
4
4
|
"description": "The Vite plugin for UnoCSS",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"unocss",
|
|
@@ -22,12 +22,12 @@
|
|
|
22
22
|
"sideEffects": false,
|
|
23
23
|
"exports": {
|
|
24
24
|
".": {
|
|
25
|
-
"require": "./dist/index.
|
|
25
|
+
"require": "./dist/index.cjs",
|
|
26
26
|
"import": "./dist/index.mjs",
|
|
27
27
|
"types": "./dist/index.d.ts"
|
|
28
28
|
}
|
|
29
29
|
},
|
|
30
|
-
"main": "dist/index.
|
|
30
|
+
"main": "dist/index.cjs",
|
|
31
31
|
"module": "dist/index.mjs",
|
|
32
32
|
"types": "dist/index.d.ts",
|
|
33
33
|
"files": [
|
|
@@ -35,16 +35,16 @@
|
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@rollup/pluginutils": "^4.1.1",
|
|
38
|
-
"@unocss/config": "0.
|
|
39
|
-
"@unocss/core": "0.
|
|
40
|
-
"@unocss/inspector": "0.
|
|
41
|
-
"@unocss/scope": "0.
|
|
38
|
+
"@unocss/config": "0.15.2",
|
|
39
|
+
"@unocss/core": "0.15.2",
|
|
40
|
+
"@unocss/inspector": "0.15.2",
|
|
41
|
+
"@unocss/scope": "0.15.2"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"vite": "^2.6.14"
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|
|
47
|
-
"build": "
|
|
48
|
-
"
|
|
47
|
+
"build": "unbuild",
|
|
48
|
+
"stub": "unbuild --stub"
|
|
49
49
|
}
|
|
50
50
|
}
|