@unocss/webpack 66.6.6-beta.1 → 66.6.7
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
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
Object.
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
+
});
|
|
5
|
+
const require_unplugin = require("./unplugin-CUhZqib4.cjs");
|
|
4
6
|
//#region src/index.ts
|
|
5
7
|
function WebpackPlugin(configOrPath, defaults) {
|
|
6
8
|
return require_unplugin.unplugin(configOrPath, defaults).webpack();
|
|
7
9
|
}
|
|
8
|
-
|
|
9
10
|
//#endregion
|
|
10
11
|
exports.WebpackPlugin = WebpackPlugin;
|
|
11
|
-
exports.default = WebpackPlugin;
|
|
12
|
+
exports.default = WebpackPlugin;
|
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { t as unplugin } from "./unplugin-
|
|
2
|
-
|
|
1
|
+
import { t as unplugin } from "./unplugin-DTW9QSY6.mjs";
|
|
3
2
|
//#region src/index.ts
|
|
4
3
|
function WebpackPlugin(configOrPath, defaults) {
|
|
5
4
|
return unplugin(configOrPath, defaults).webpack();
|
|
6
5
|
}
|
|
7
|
-
|
|
8
6
|
//#endregion
|
|
9
|
-
export { WebpackPlugin, WebpackPlugin as default };
|
|
7
|
+
export { WebpackPlugin, WebpackPlugin as default };
|
package/dist/rspack.cjs
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_unplugin = require("./unplugin-CUhZqib4.cjs");
|
|
3
3
|
//#region src/rspack.ts
|
|
4
4
|
function UnoCSSRspackPlugin(configOrPath, defaults) {
|
|
5
5
|
return require_unplugin.unplugin(configOrPath, defaults).rspack();
|
|
6
6
|
}
|
|
7
|
-
|
|
8
7
|
//#endregion
|
|
9
|
-
exports.UnoCSSRspackPlugin = UnoCSSRspackPlugin;
|
|
8
|
+
exports.UnoCSSRspackPlugin = UnoCSSRspackPlugin;
|
package/dist/rspack.mjs
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { t as unplugin } from "./unplugin-
|
|
2
|
-
|
|
1
|
+
import { t as unplugin } from "./unplugin-DTW9QSY6.mjs";
|
|
3
2
|
//#region src/rspack.ts
|
|
4
3
|
function UnoCSSRspackPlugin(configOrPath, defaults) {
|
|
5
4
|
return unplugin(configOrPath, defaults).rspack();
|
|
6
5
|
}
|
|
7
|
-
|
|
8
6
|
//#endregion
|
|
9
|
-
export { UnoCSSRspackPlugin };
|
|
7
|
+
export { UnoCSSRspackPlugin };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
2
|
var __create = Object.create;
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -6,16 +6,12 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
8
|
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
}
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
+
key = keys[i];
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
+
get: ((k) => from[k]).bind(null, key),
|
|
13
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
+
});
|
|
19
15
|
}
|
|
20
16
|
return to;
|
|
21
17
|
};
|
|
@@ -23,7 +19,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
23
19
|
value: mod,
|
|
24
20
|
enumerable: true
|
|
25
21
|
}) : target, mod));
|
|
26
|
-
|
|
27
22
|
//#endregion
|
|
28
23
|
let node_path = require("node:path");
|
|
29
24
|
let node_process = require("node:process");
|
|
@@ -44,17 +39,10 @@ let pathe = require("pathe");
|
|
|
44
39
|
let unplugin = require("unplugin");
|
|
45
40
|
let webpack_sources = require("webpack-sources");
|
|
46
41
|
webpack_sources = __toESM(webpack_sources);
|
|
47
|
-
|
|
48
|
-
//#region ../../virtual-shared/integration/src/constants.ts
|
|
49
|
-
const INCLUDE_COMMENT = "@unocss-include";
|
|
50
|
-
const IGNORE_COMMENT = "@unocss-ignore";
|
|
51
|
-
const CSS_PLACEHOLDER = "@unocss-placeholder";
|
|
52
42
|
const SKIP_START_COMMENT = "@unocss-skip-start";
|
|
53
43
|
const SKIP_END_COMMENT = "@unocss-skip-end";
|
|
54
44
|
const SKIP_COMMENT_RE = new RegExp(`(\/\/\\s*?${SKIP_START_COMMENT}\\s*?|\\/\\*\\s*?${SKIP_START_COMMENT}\\s*?\\*\\/|<!--\\s*?${SKIP_START_COMMENT}\\s*?-->)[\\s\\S]*?(\/\/\\s*?${SKIP_END_COMMENT}\\s*?|\\/\\*\\s*?${SKIP_END_COMMENT}\\s*?\\*\\/|<!--\\s*?${SKIP_END_COMMENT}\\s*?-->)`, "g");
|
|
55
45
|
const VIRTUAL_ENTRY_ALIAS = [/^(?:virtual:)?uno(?::(.+))?\.css(\?.*)?$/];
|
|
56
|
-
const LAYER_MARK_ALL = "__ALL__";
|
|
57
|
-
|
|
58
46
|
//#endregion
|
|
59
47
|
//#region ../../virtual-shared/integration/src/utils.ts
|
|
60
48
|
function getPath(id) {
|
|
@@ -86,11 +74,10 @@ function restoreSkipCode(code, map) {
|
|
|
86
74
|
for (const [withHashKey, matched] of map.entries()) code = code.replaceAll(withHashKey, matched);
|
|
87
75
|
return code;
|
|
88
76
|
}
|
|
89
|
-
|
|
90
77
|
//#endregion
|
|
91
78
|
//#region ../../virtual-shared/integration/src/transformers.ts
|
|
92
79
|
async function applyTransformers(ctx, original, id, enforce = "default") {
|
|
93
|
-
if (original.includes(
|
|
80
|
+
if (original.includes("@unocss-ignore")) return;
|
|
94
81
|
const transformers = (ctx.uno.config.transformers || []).filter((i) => (i.enforce || "default") === enforce);
|
|
95
82
|
if (!transformers.length) return;
|
|
96
83
|
const skipMap = /* @__PURE__ */ new Map();
|
|
@@ -113,13 +100,12 @@ async function applyTransformers(ctx, original, id, enforce = "default") {
|
|
|
113
100
|
}
|
|
114
101
|
if (code !== original) return {
|
|
115
102
|
code,
|
|
116
|
-
map: (0, _jridgewell_remapping.default)(maps, (_, ctx
|
|
117
|
-
ctx
|
|
103
|
+
map: (0, _jridgewell_remapping.default)(maps, (_, ctx) => {
|
|
104
|
+
ctx.content = code;
|
|
118
105
|
return null;
|
|
119
106
|
})
|
|
120
107
|
};
|
|
121
108
|
}
|
|
122
|
-
|
|
123
109
|
//#endregion
|
|
124
110
|
//#region ../../virtual-shared/integration/src/content.ts
|
|
125
111
|
async function setupContentExtractor(ctx, shouldWatch = false) {
|
|
@@ -160,16 +146,10 @@ async function setupContentExtractor(ctx, shouldWatch = false) {
|
|
|
160
146
|
await Promise.all(files.map(extractFile));
|
|
161
147
|
}
|
|
162
148
|
}
|
|
163
|
-
|
|
164
149
|
//#endregion
|
|
165
150
|
//#region ../../virtual-shared/integration/src/defaults.ts
|
|
166
151
|
const defaultPipelineExclude = [_unocss_core.cssIdRE];
|
|
167
152
|
const defaultPipelineInclude = [/\.(vue|svelte|[jt]sx|vine.ts|mdx?|astro|elm|php|phtml|marko|html)($|\?)/];
|
|
168
|
-
|
|
169
|
-
//#endregion
|
|
170
|
-
//#region ../../virtual-shared/integration/src/deprecation.ts
|
|
171
|
-
function deprecationCheck(config) {}
|
|
172
|
-
|
|
173
153
|
//#endregion
|
|
174
154
|
//#region ../../virtual-shared/integration/src/context.ts
|
|
175
155
|
function createContext(configOrPath, defaults = {}, extraConfigSources = [], resolveConfigResult = () => {}) {
|
|
@@ -194,7 +174,7 @@ function createContext(configOrPath, defaults = {}, extraConfigSources = [], res
|
|
|
194
174
|
await _uno;
|
|
195
175
|
const result = await loadConfig(root, configOrPath, extraConfigSources, defaults);
|
|
196
176
|
resolveConfigResult(result);
|
|
197
|
-
|
|
177
|
+
result.config;
|
|
198
178
|
rawConfig = result.config;
|
|
199
179
|
configFileList = result.sources;
|
|
200
180
|
await uno.setConfig(rawConfig);
|
|
@@ -220,15 +200,15 @@ function createContext(configOrPath, defaults = {}, extraConfigSources = [], res
|
|
|
220
200
|
reloadListeners.forEach((cb) => cb());
|
|
221
201
|
}
|
|
222
202
|
async function extract(code, id) {
|
|
223
|
-
const uno
|
|
203
|
+
const uno = await _uno;
|
|
224
204
|
if (id) modules.set(id, code);
|
|
225
205
|
const len = tokens.size;
|
|
226
|
-
await uno
|
|
206
|
+
await uno.applyExtractors(code.replace(SKIP_COMMENT_RE, ""), id, tokens);
|
|
227
207
|
if (tokens.size > len) invalidate();
|
|
228
208
|
}
|
|
229
209
|
function filter(code, id) {
|
|
230
|
-
if (code.includes(
|
|
231
|
-
return code.includes(
|
|
210
|
+
if (code.includes("@unocss-ignore")) return false;
|
|
211
|
+
return code.includes("@unocss-include") || code.includes("@unocss-placeholder") || rollupFilter(id.replace(/\?v=\w+$/, ""));
|
|
232
212
|
}
|
|
233
213
|
async function getConfig() {
|
|
234
214
|
await ready;
|
|
@@ -248,8 +228,8 @@ function createContext(configOrPath, defaults = {}, extraConfigSources = [], res
|
|
|
248
228
|
if (vmpCache.has(prefix)) return vmpCache.get(prefix);
|
|
249
229
|
const regexes = {
|
|
250
230
|
prefix,
|
|
251
|
-
RESOLVED_ID_WITH_QUERY_RE:
|
|
252
|
-
RESOLVED_ID_RE:
|
|
231
|
+
RESOLVED_ID_WITH_QUERY_RE: new RegExp(`[/\\\\]${prefix}(_.*?)?\\.css(\\?.*)?$`),
|
|
232
|
+
RESOLVED_ID_RE: new RegExp(`[/\\\\]${prefix}(?:_(.*?))?\.css$`)
|
|
253
233
|
};
|
|
254
234
|
vmpCache.set(prefix, regexes);
|
|
255
235
|
return regexes;
|
|
@@ -286,14 +266,12 @@ function createContext(configOrPath, defaults = {}, extraConfigSources = [], res
|
|
|
286
266
|
getVMPRegexes
|
|
287
267
|
};
|
|
288
268
|
}
|
|
289
|
-
|
|
290
269
|
//#endregion
|
|
291
270
|
//#region ../../virtual-shared/integration/src/hash.ts
|
|
292
271
|
const hash = node_crypto.default.hash ?? ((algorithm, data, outputEncoding) => node_crypto.default.createHash(algorithm).update(data).digest(outputEncoding));
|
|
293
272
|
function getHash(input, length = 8) {
|
|
294
273
|
return hash("sha256", input, "hex").substring(0, length);
|
|
295
274
|
}
|
|
296
|
-
|
|
297
275
|
//#endregion
|
|
298
276
|
//#region ../../virtual-shared/integration/src/layers.ts
|
|
299
277
|
async function resolveId(ctx, id, importer) {
|
|
@@ -313,7 +291,7 @@ async function resolveId(ctx, id, importer) {
|
|
|
313
291
|
async function resolveLayer(ctx, id) {
|
|
314
292
|
const { RESOLVED_ID_RE } = await ctx.getVMPRegexes();
|
|
315
293
|
const match = id.match(RESOLVED_ID_RE);
|
|
316
|
-
if (match) return match[1] ||
|
|
294
|
+
if (match) return match[1] || "__ALL__";
|
|
317
295
|
}
|
|
318
296
|
/**
|
|
319
297
|
* 1 - layer
|
|
@@ -336,10 +314,9 @@ function getCssEscaperForJsContent(view) {
|
|
|
336
314
|
});
|
|
337
315
|
}
|
|
338
316
|
const HASH_PLACEHOLDER_RE = /#--unocss-hash--\s*\{\s*content\s*:\s*\\*"([^\\"]+)\\*";?\s*\}/g;
|
|
339
|
-
function getHashPlaceholder(hash
|
|
340
|
-
return `#--unocss-hash--{content:"${hash
|
|
317
|
+
function getHashPlaceholder(hash) {
|
|
318
|
+
return `#--unocss-hash--{content:"${hash}"}`;
|
|
341
319
|
}
|
|
342
|
-
|
|
343
320
|
//#endregion
|
|
344
321
|
//#region src/unplugin.ts
|
|
345
322
|
const PLUGIN_NAME = "unocss:webpack";
|
|
@@ -385,8 +362,8 @@ function unplugin$1(configOrPath, defaults) {
|
|
|
385
362
|
async load(id) {
|
|
386
363
|
const layer = await getLayer(ctx, id);
|
|
387
364
|
if (!layer) return;
|
|
388
|
-
const hash
|
|
389
|
-
return (hash
|
|
365
|
+
const hash = hashes.get(id);
|
|
366
|
+
return (hash ? getHashPlaceholder(hash) : "") + getLayerPlaceholder(layer);
|
|
390
367
|
},
|
|
391
368
|
webpack(compiler) {
|
|
392
369
|
compiler.hooks.beforeCompile.tapPromise(PLUGIN_NAME, async () => {
|
|
@@ -409,7 +386,7 @@ function unplugin$1(configOrPath, defaults) {
|
|
|
409
386
|
code = code.replace(HASH_PLACEHOLDER_RE, "");
|
|
410
387
|
code = code.replace(LAYER_PLACEHOLDER_RE, (_, layer, escapeView) => {
|
|
411
388
|
replaced = true;
|
|
412
|
-
const css = layer.trim() ===
|
|
389
|
+
const css = layer.trim() === "__ALL__" ? result.getLayers(void 0, resolvedLayers) : result.getLayer(layer) || "";
|
|
413
390
|
escapeCss = escapeCss ?? getCssEscaperForJsContent(escapeView.trim());
|
|
414
391
|
return escapeCss(css);
|
|
415
392
|
});
|
|
@@ -438,9 +415,9 @@ function unplugin$1(configOrPath, defaults) {
|
|
|
438
415
|
path = normalizeAbsolutePath(path);
|
|
439
416
|
const layer = await resolveLayer(ctx, path);
|
|
440
417
|
if (!layer) continue;
|
|
441
|
-
const code = layer ===
|
|
442
|
-
const hash
|
|
443
|
-
hashes.set(path, hash
|
|
418
|
+
const code = layer === "__ALL__" ? result.getLayers(void 0, resolvedLayers) : result.getLayer(layer) || "";
|
|
419
|
+
const hash = getHash(code);
|
|
420
|
+
hashes.set(path, hash);
|
|
444
421
|
plugin.__vfs.writeModule(id, code);
|
|
445
422
|
}
|
|
446
423
|
}
|
|
@@ -459,11 +436,10 @@ function normalizeAbsolutePath(path) {
|
|
|
459
436
|
if ((0, node_path.isAbsolute)(path)) return (0, node_path.normalize)(path);
|
|
460
437
|
else return path;
|
|
461
438
|
}
|
|
462
|
-
|
|
463
439
|
//#endregion
|
|
464
|
-
Object.defineProperty(exports,
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
});
|
|
440
|
+
Object.defineProperty(exports, "unplugin", {
|
|
441
|
+
enumerable: true,
|
|
442
|
+
get: function() {
|
|
443
|
+
return unplugin$1;
|
|
444
|
+
}
|
|
445
|
+
});
|
|
@@ -11,17 +11,10 @@ import crypto from "node:crypto";
|
|
|
11
11
|
import { resolve as resolve$1 } from "pathe";
|
|
12
12
|
import { createUnplugin } from "unplugin";
|
|
13
13
|
import WebpackSources from "webpack-sources";
|
|
14
|
-
|
|
15
|
-
//#region ../../virtual-shared/integration/src/constants.ts
|
|
16
|
-
const INCLUDE_COMMENT = "@unocss-include";
|
|
17
|
-
const IGNORE_COMMENT = "@unocss-ignore";
|
|
18
|
-
const CSS_PLACEHOLDER = "@unocss-placeholder";
|
|
19
14
|
const SKIP_START_COMMENT = "@unocss-skip-start";
|
|
20
15
|
const SKIP_END_COMMENT = "@unocss-skip-end";
|
|
21
16
|
const SKIP_COMMENT_RE = new RegExp(`(\/\/\\s*?${SKIP_START_COMMENT}\\s*?|\\/\\*\\s*?${SKIP_START_COMMENT}\\s*?\\*\\/|<!--\\s*?${SKIP_START_COMMENT}\\s*?-->)[\\s\\S]*?(\/\/\\s*?${SKIP_END_COMMENT}\\s*?|\\/\\*\\s*?${SKIP_END_COMMENT}\\s*?\\*\\/|<!--\\s*?${SKIP_END_COMMENT}\\s*?-->)`, "g");
|
|
22
17
|
const VIRTUAL_ENTRY_ALIAS = [/^(?:virtual:)?uno(?::(.+))?\.css(\?.*)?$/];
|
|
23
|
-
const LAYER_MARK_ALL = "__ALL__";
|
|
24
|
-
|
|
25
18
|
//#endregion
|
|
26
19
|
//#region ../../virtual-shared/integration/src/utils.ts
|
|
27
20
|
function getPath(id) {
|
|
@@ -53,11 +46,10 @@ function restoreSkipCode(code, map) {
|
|
|
53
46
|
for (const [withHashKey, matched] of map.entries()) code = code.replaceAll(withHashKey, matched);
|
|
54
47
|
return code;
|
|
55
48
|
}
|
|
56
|
-
|
|
57
49
|
//#endregion
|
|
58
50
|
//#region ../../virtual-shared/integration/src/transformers.ts
|
|
59
51
|
async function applyTransformers(ctx, original, id, enforce = "default") {
|
|
60
|
-
if (original.includes(
|
|
52
|
+
if (original.includes("@unocss-ignore")) return;
|
|
61
53
|
const transformers = (ctx.uno.config.transformers || []).filter((i) => (i.enforce || "default") === enforce);
|
|
62
54
|
if (!transformers.length) return;
|
|
63
55
|
const skipMap = /* @__PURE__ */ new Map();
|
|
@@ -80,13 +72,12 @@ async function applyTransformers(ctx, original, id, enforce = "default") {
|
|
|
80
72
|
}
|
|
81
73
|
if (code !== original) return {
|
|
82
74
|
code,
|
|
83
|
-
map: remapping(maps, (_, ctx
|
|
84
|
-
ctx
|
|
75
|
+
map: remapping(maps, (_, ctx) => {
|
|
76
|
+
ctx.content = code;
|
|
85
77
|
return null;
|
|
86
78
|
})
|
|
87
79
|
};
|
|
88
80
|
}
|
|
89
|
-
|
|
90
81
|
//#endregion
|
|
91
82
|
//#region ../../virtual-shared/integration/src/content.ts
|
|
92
83
|
async function setupContentExtractor(ctx, shouldWatch = false) {
|
|
@@ -127,16 +118,10 @@ async function setupContentExtractor(ctx, shouldWatch = false) {
|
|
|
127
118
|
await Promise.all(files.map(extractFile));
|
|
128
119
|
}
|
|
129
120
|
}
|
|
130
|
-
|
|
131
121
|
//#endregion
|
|
132
122
|
//#region ../../virtual-shared/integration/src/defaults.ts
|
|
133
123
|
const defaultPipelineExclude = [cssIdRE];
|
|
134
124
|
const defaultPipelineInclude = [/\.(vue|svelte|[jt]sx|vine.ts|mdx?|astro|elm|php|phtml|marko|html)($|\?)/];
|
|
135
|
-
|
|
136
|
-
//#endregion
|
|
137
|
-
//#region ../../virtual-shared/integration/src/deprecation.ts
|
|
138
|
-
function deprecationCheck(config) {}
|
|
139
|
-
|
|
140
125
|
//#endregion
|
|
141
126
|
//#region ../../virtual-shared/integration/src/context.ts
|
|
142
127
|
function createContext(configOrPath, defaults = {}, extraConfigSources = [], resolveConfigResult = () => {}) {
|
|
@@ -161,7 +146,7 @@ function createContext(configOrPath, defaults = {}, extraConfigSources = [], res
|
|
|
161
146
|
await _uno;
|
|
162
147
|
const result = await loadConfig(root, configOrPath, extraConfigSources, defaults);
|
|
163
148
|
resolveConfigResult(result);
|
|
164
|
-
|
|
149
|
+
result.config;
|
|
165
150
|
rawConfig = result.config;
|
|
166
151
|
configFileList = result.sources;
|
|
167
152
|
await uno.setConfig(rawConfig);
|
|
@@ -187,15 +172,15 @@ function createContext(configOrPath, defaults = {}, extraConfigSources = [], res
|
|
|
187
172
|
reloadListeners.forEach((cb) => cb());
|
|
188
173
|
}
|
|
189
174
|
async function extract(code, id) {
|
|
190
|
-
const uno
|
|
175
|
+
const uno = await _uno;
|
|
191
176
|
if (id) modules.set(id, code);
|
|
192
177
|
const len = tokens.size;
|
|
193
|
-
await uno
|
|
178
|
+
await uno.applyExtractors(code.replace(SKIP_COMMENT_RE, ""), id, tokens);
|
|
194
179
|
if (tokens.size > len) invalidate();
|
|
195
180
|
}
|
|
196
181
|
function filter(code, id) {
|
|
197
|
-
if (code.includes(
|
|
198
|
-
return code.includes(
|
|
182
|
+
if (code.includes("@unocss-ignore")) return false;
|
|
183
|
+
return code.includes("@unocss-include") || code.includes("@unocss-placeholder") || rollupFilter(id.replace(/\?v=\w+$/, ""));
|
|
199
184
|
}
|
|
200
185
|
async function getConfig() {
|
|
201
186
|
await ready;
|
|
@@ -215,8 +200,8 @@ function createContext(configOrPath, defaults = {}, extraConfigSources = [], res
|
|
|
215
200
|
if (vmpCache.has(prefix)) return vmpCache.get(prefix);
|
|
216
201
|
const regexes = {
|
|
217
202
|
prefix,
|
|
218
|
-
RESOLVED_ID_WITH_QUERY_RE:
|
|
219
|
-
RESOLVED_ID_RE:
|
|
203
|
+
RESOLVED_ID_WITH_QUERY_RE: new RegExp(`[/\\\\]${prefix}(_.*?)?\\.css(\\?.*)?$`),
|
|
204
|
+
RESOLVED_ID_RE: new RegExp(`[/\\\\]${prefix}(?:_(.*?))?\.css$`)
|
|
220
205
|
};
|
|
221
206
|
vmpCache.set(prefix, regexes);
|
|
222
207
|
return regexes;
|
|
@@ -253,14 +238,12 @@ function createContext(configOrPath, defaults = {}, extraConfigSources = [], res
|
|
|
253
238
|
getVMPRegexes
|
|
254
239
|
};
|
|
255
240
|
}
|
|
256
|
-
|
|
257
241
|
//#endregion
|
|
258
242
|
//#region ../../virtual-shared/integration/src/hash.ts
|
|
259
243
|
const hash = crypto.hash ?? ((algorithm, data, outputEncoding) => crypto.createHash(algorithm).update(data).digest(outputEncoding));
|
|
260
244
|
function getHash(input, length = 8) {
|
|
261
245
|
return hash("sha256", input, "hex").substring(0, length);
|
|
262
246
|
}
|
|
263
|
-
|
|
264
247
|
//#endregion
|
|
265
248
|
//#region ../../virtual-shared/integration/src/layers.ts
|
|
266
249
|
async function resolveId(ctx, id, importer) {
|
|
@@ -280,7 +263,7 @@ async function resolveId(ctx, id, importer) {
|
|
|
280
263
|
async function resolveLayer(ctx, id) {
|
|
281
264
|
const { RESOLVED_ID_RE } = await ctx.getVMPRegexes();
|
|
282
265
|
const match = id.match(RESOLVED_ID_RE);
|
|
283
|
-
if (match) return match[1] ||
|
|
266
|
+
if (match) return match[1] || "__ALL__";
|
|
284
267
|
}
|
|
285
268
|
/**
|
|
286
269
|
* 1 - layer
|
|
@@ -303,10 +286,9 @@ function getCssEscaperForJsContent(view) {
|
|
|
303
286
|
});
|
|
304
287
|
}
|
|
305
288
|
const HASH_PLACEHOLDER_RE = /#--unocss-hash--\s*\{\s*content\s*:\s*\\*"([^\\"]+)\\*";?\s*\}/g;
|
|
306
|
-
function getHashPlaceholder(hash
|
|
307
|
-
return `#--unocss-hash--{content:"${hash
|
|
289
|
+
function getHashPlaceholder(hash) {
|
|
290
|
+
return `#--unocss-hash--{content:"${hash}"}`;
|
|
308
291
|
}
|
|
309
|
-
|
|
310
292
|
//#endregion
|
|
311
293
|
//#region src/unplugin.ts
|
|
312
294
|
const PLUGIN_NAME = "unocss:webpack";
|
|
@@ -352,8 +334,8 @@ function unplugin(configOrPath, defaults) {
|
|
|
352
334
|
async load(id) {
|
|
353
335
|
const layer = await getLayer(ctx, id);
|
|
354
336
|
if (!layer) return;
|
|
355
|
-
const hash
|
|
356
|
-
return (hash
|
|
337
|
+
const hash = hashes.get(id);
|
|
338
|
+
return (hash ? getHashPlaceholder(hash) : "") + getLayerPlaceholder(layer);
|
|
357
339
|
},
|
|
358
340
|
webpack(compiler) {
|
|
359
341
|
compiler.hooks.beforeCompile.tapPromise(PLUGIN_NAME, async () => {
|
|
@@ -376,7 +358,7 @@ function unplugin(configOrPath, defaults) {
|
|
|
376
358
|
code = code.replace(HASH_PLACEHOLDER_RE, "");
|
|
377
359
|
code = code.replace(LAYER_PLACEHOLDER_RE, (_, layer, escapeView) => {
|
|
378
360
|
replaced = true;
|
|
379
|
-
const css = layer.trim() ===
|
|
361
|
+
const css = layer.trim() === "__ALL__" ? result.getLayers(void 0, resolvedLayers) : result.getLayer(layer) || "";
|
|
380
362
|
escapeCss = escapeCss ?? getCssEscaperForJsContent(escapeView.trim());
|
|
381
363
|
return escapeCss(css);
|
|
382
364
|
});
|
|
@@ -405,9 +387,9 @@ function unplugin(configOrPath, defaults) {
|
|
|
405
387
|
path = normalizeAbsolutePath(path);
|
|
406
388
|
const layer = await resolveLayer(ctx, path);
|
|
407
389
|
if (!layer) continue;
|
|
408
|
-
const code = layer ===
|
|
409
|
-
const hash
|
|
410
|
-
hashes.set(path, hash
|
|
390
|
+
const code = layer === "__ALL__" ? result.getLayers(void 0, resolvedLayers) : result.getLayer(layer) || "";
|
|
391
|
+
const hash = getHash(code);
|
|
392
|
+
hashes.set(path, hash);
|
|
411
393
|
plugin.__vfs.writeModule(id, code);
|
|
412
394
|
}
|
|
413
395
|
}
|
|
@@ -426,6 +408,5 @@ function normalizeAbsolutePath(path) {
|
|
|
426
408
|
if (isAbsolute(path)) return normalize(path);
|
|
427
409
|
else return path;
|
|
428
410
|
}
|
|
429
|
-
|
|
430
411
|
//#endregion
|
|
431
|
-
export { unplugin as t };
|
|
412
|
+
export { unplugin as t };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unocss/webpack",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "66.6.
|
|
4
|
+
"version": "66.6.7",
|
|
5
5
|
"description": "The Webpack plugin for UnoCSS",
|
|
6
6
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -22,12 +22,12 @@
|
|
|
22
22
|
"sideEffects": false,
|
|
23
23
|
"exports": {
|
|
24
24
|
".": {
|
|
25
|
-
"
|
|
26
|
-
"
|
|
25
|
+
"import": "./dist/index.mjs",
|
|
26
|
+
"require": "./dist/index.cjs"
|
|
27
27
|
},
|
|
28
28
|
"./rspack": {
|
|
29
|
-
"
|
|
30
|
-
"
|
|
29
|
+
"import": "./dist/rspack.mjs",
|
|
30
|
+
"require": "./dist/rspack.cjs"
|
|
31
31
|
},
|
|
32
32
|
"./package.json": "./package.json"
|
|
33
33
|
},
|
|
@@ -57,8 +57,8 @@
|
|
|
57
57
|
"unplugin": "^2.3.11",
|
|
58
58
|
"unplugin-utils": "^0.3.1",
|
|
59
59
|
"webpack-sources": "^3.3.4",
|
|
60
|
-
"@unocss/config": "66.6.
|
|
61
|
-
"@unocss/core": "66.6.
|
|
60
|
+
"@unocss/config": "66.6.7",
|
|
61
|
+
"@unocss/core": "66.6.7"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
64
|
"webpack": "^5.105.2"
|