@unocss/vite 0.43.1 → 0.43.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.cjs +17 -6
- package/dist/index.mjs +17 -6
- package/package.json +7 -7
package/dist/index.cjs
CHANGED
|
@@ -326,9 +326,10 @@ function GlobalModeBuildPlugin({ uno, ready, extract, tokens, filter, getConfig
|
|
|
326
326
|
},
|
|
327
327
|
enforce: "post",
|
|
328
328
|
async generateBundle(options, bundle) {
|
|
329
|
-
const files = Object.
|
|
330
|
-
const cssFiles = files.filter((i) => i.endsWith(".css"));
|
|
331
|
-
|
|
329
|
+
const files = Object.entries(bundle);
|
|
330
|
+
const cssFiles = files.filter((i) => i[0].endsWith(".css"));
|
|
331
|
+
const jsFiles = files.filter((i) => i[0].endsWith(".js"));
|
|
332
|
+
if (!cssFiles.length && !jsFiles.length)
|
|
332
333
|
return;
|
|
333
334
|
if (!vfsLayers.size) {
|
|
334
335
|
const msg = "[unocss] entry module not found, have you add `import 'uno.css'` in your main entry?";
|
|
@@ -337,13 +338,23 @@ function GlobalModeBuildPlugin({ uno, ready, extract, tokens, filter, getConfig
|
|
|
337
338
|
}
|
|
338
339
|
const result = await generateAll();
|
|
339
340
|
let replaced = false;
|
|
340
|
-
for (const
|
|
341
|
-
const chunk = bundle[file];
|
|
341
|
+
for (const [, chunk] of cssFiles) {
|
|
342
342
|
if (chunk.type === "asset" && typeof chunk.source === "string") {
|
|
343
343
|
const css = chunk.source.replace(HASH_PLACEHOLDER_RE, "");
|
|
344
344
|
chunk.source = await replaceAsync(css, LAYER_PLACEHOLDER_RE, async (_, __, layer) => {
|
|
345
345
|
replaced = true;
|
|
346
|
-
|
|
346
|
+
const css2 = layer === LAYER_MARK_ALL ? result.getLayers(void 0, Array.from(vfsLayers)) : result.getLayer(layer) || "";
|
|
347
|
+
return await applyCssTransform(css2, `${chunk.fileName}.css`, options.dir);
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
for (const [, chunk] of jsFiles) {
|
|
352
|
+
if (chunk.type === "chunk" && typeof chunk.code === "string") {
|
|
353
|
+
const js = chunk.code.replace(HASH_PLACEHOLDER_RE, "");
|
|
354
|
+
chunk.code = await replaceAsync(js, LAYER_PLACEHOLDER_RE, async (_, __, layer) => {
|
|
355
|
+
replaced = true;
|
|
356
|
+
const css = layer === LAYER_MARK_ALL ? result.getLayers(void 0, Array.from(vfsLayers)) : result.getLayer(layer) || "";
|
|
357
|
+
return css;
|
|
347
358
|
});
|
|
348
359
|
}
|
|
349
360
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -316,9 +316,10 @@ function GlobalModeBuildPlugin({ uno, ready, extract, tokens, filter, getConfig
|
|
|
316
316
|
},
|
|
317
317
|
enforce: "post",
|
|
318
318
|
async generateBundle(options, bundle) {
|
|
319
|
-
const files = Object.
|
|
320
|
-
const cssFiles = files.filter((i) => i.endsWith(".css"));
|
|
321
|
-
|
|
319
|
+
const files = Object.entries(bundle);
|
|
320
|
+
const cssFiles = files.filter((i) => i[0].endsWith(".css"));
|
|
321
|
+
const jsFiles = files.filter((i) => i[0].endsWith(".js"));
|
|
322
|
+
if (!cssFiles.length && !jsFiles.length)
|
|
322
323
|
return;
|
|
323
324
|
if (!vfsLayers.size) {
|
|
324
325
|
const msg = "[unocss] entry module not found, have you add `import 'uno.css'` in your main entry?";
|
|
@@ -327,13 +328,23 @@ function GlobalModeBuildPlugin({ uno, ready, extract, tokens, filter, getConfig
|
|
|
327
328
|
}
|
|
328
329
|
const result = await generateAll();
|
|
329
330
|
let replaced = false;
|
|
330
|
-
for (const
|
|
331
|
-
const chunk = bundle[file];
|
|
331
|
+
for (const [, chunk] of cssFiles) {
|
|
332
332
|
if (chunk.type === "asset" && typeof chunk.source === "string") {
|
|
333
333
|
const css = chunk.source.replace(HASH_PLACEHOLDER_RE, "");
|
|
334
334
|
chunk.source = await replaceAsync(css, LAYER_PLACEHOLDER_RE, async (_, __, layer) => {
|
|
335
335
|
replaced = true;
|
|
336
|
-
|
|
336
|
+
const css2 = layer === LAYER_MARK_ALL ? result.getLayers(void 0, Array.from(vfsLayers)) : result.getLayer(layer) || "";
|
|
337
|
+
return await applyCssTransform(css2, `${chunk.fileName}.css`, options.dir);
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
for (const [, chunk] of jsFiles) {
|
|
342
|
+
if (chunk.type === "chunk" && typeof chunk.code === "string") {
|
|
343
|
+
const js = chunk.code.replace(HASH_PLACEHOLDER_RE, "");
|
|
344
|
+
chunk.code = await replaceAsync(js, LAYER_PLACEHOLDER_RE, async (_, __, layer) => {
|
|
345
|
+
replaced = true;
|
|
346
|
+
const css = layer === LAYER_MARK_ALL ? result.getLayers(void 0, Array.from(vfsLayers)) : result.getLayer(layer) || "";
|
|
347
|
+
return css;
|
|
337
348
|
});
|
|
338
349
|
}
|
|
339
350
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unocss/vite",
|
|
3
|
-
"version": "0.43.
|
|
3
|
+
"version": "0.43.2",
|
|
4
4
|
"description": "The Vite plugin for UnoCSS",
|
|
5
5
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -43,15 +43,15 @@
|
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@rollup/pluginutils": "^4.2.1",
|
|
46
|
-
"@unocss/config": "0.43.
|
|
47
|
-
"@unocss/core": "0.43.
|
|
48
|
-
"@unocss/inspector": "0.43.
|
|
49
|
-
"@unocss/scope": "0.43.
|
|
50
|
-
"@unocss/transformer-directives": "0.43.
|
|
46
|
+
"@unocss/config": "0.43.2",
|
|
47
|
+
"@unocss/core": "0.43.2",
|
|
48
|
+
"@unocss/inspector": "0.43.2",
|
|
49
|
+
"@unocss/scope": "0.43.2",
|
|
50
|
+
"@unocss/transformer-directives": "0.43.2",
|
|
51
51
|
"magic-string": "^0.26.2"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@unocss/shared-integration": "0.43.
|
|
54
|
+
"@unocss/shared-integration": "0.43.2",
|
|
55
55
|
"vite": "^2.9.12"
|
|
56
56
|
},
|
|
57
57
|
"scripts": {
|