@unocss/vite 0.38.0 → 0.38.1
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 +14 -14
- package/dist/index.mjs +14 -14
- package/package.json +7 -7
package/dist/index.cjs
CHANGED
|
@@ -206,15 +206,15 @@ function GlobalModeBuildPlugin({ uno, ready, extract, tokens, modules, filter, g
|
|
|
206
206
|
const vfsLayerMap = /* @__PURE__ */ new Map();
|
|
207
207
|
const layerImporterMap = /* @__PURE__ */ new Map();
|
|
208
208
|
let tasks = [];
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
async function transformCSS(css, id) {
|
|
209
|
+
const cssPostPlugins = /* @__PURE__ */ new Map();
|
|
210
|
+
const cssPlugins = /* @__PURE__ */ new Map();
|
|
211
|
+
async function transformCSS(css, id, dir) {
|
|
212
212
|
const {
|
|
213
213
|
postcss = true
|
|
214
214
|
} = await getConfig();
|
|
215
|
-
if (!
|
|
215
|
+
if (!cssPlugins.get(dir) || !postcss)
|
|
216
216
|
return css;
|
|
217
|
-
const result = await
|
|
217
|
+
const result = await cssPlugins.get(dir).transform(css, id);
|
|
218
218
|
if (!result)
|
|
219
219
|
return css;
|
|
220
220
|
if (typeof result === "string")
|
|
@@ -267,12 +267,12 @@ function GlobalModeBuildPlugin({ uno, ready, extract, tokens, modules, filter, g
|
|
|
267
267
|
}
|
|
268
268
|
},
|
|
269
269
|
async configResolved(config) {
|
|
270
|
-
|
|
271
|
-
|
|
270
|
+
cssPostPlugins.set(config.build.outDir, config.plugins.find((i) => i.name === "vite:css-post"));
|
|
271
|
+
cssPlugins.set(config.build.outDir, config.plugins.find((i) => i.name === "vite:css"));
|
|
272
272
|
await ready;
|
|
273
273
|
},
|
|
274
|
-
async renderChunk(_, chunk) {
|
|
275
|
-
if (!
|
|
274
|
+
async renderChunk(_, chunk, options) {
|
|
275
|
+
if (!cssPostPlugins.get(options.dir))
|
|
276
276
|
return null;
|
|
277
277
|
const chunks = Object.keys(chunk.modules).filter((i) => modules.has(i));
|
|
278
278
|
if (!chunks.length)
|
|
@@ -285,9 +285,9 @@ function GlobalModeBuildPlugin({ uno, ready, extract, tokens, modules, filter, g
|
|
|
285
285
|
return null;
|
|
286
286
|
if (!Object.keys(chunk.modules).some((i) => i.match(RESOLVED_ID_RE)))
|
|
287
287
|
return null;
|
|
288
|
-
css = await transformCSS(css, fakeCssId);
|
|
288
|
+
css = await transformCSS(css, fakeCssId, options.dir);
|
|
289
289
|
const hash = getHash(css);
|
|
290
|
-
await
|
|
290
|
+
await cssPostPlugins.get(options.dir).transform(getHashPlaceholder(hash), fakeCssId);
|
|
291
291
|
chunk.modules[fakeCssId] = {
|
|
292
292
|
code: null,
|
|
293
293
|
originalLength: 0,
|
|
@@ -304,7 +304,7 @@ function GlobalModeBuildPlugin({ uno, ready, extract, tokens, modules, filter, g
|
|
|
304
304
|
return command === "build" && !options.build?.ssr;
|
|
305
305
|
},
|
|
306
306
|
enforce: "post",
|
|
307
|
-
async generateBundle(
|
|
307
|
+
async generateBundle(options, bundle) {
|
|
308
308
|
const files = Object.keys(bundle);
|
|
309
309
|
const cssFiles = files.filter((i) => i.endsWith(".css"));
|
|
310
310
|
if (!cssFiles.length)
|
|
@@ -321,9 +321,9 @@ function GlobalModeBuildPlugin({ uno, ready, extract, tokens, modules, filter, g
|
|
|
321
321
|
const chunk = bundle[file];
|
|
322
322
|
if (chunk.type === "asset" && typeof chunk.source === "string") {
|
|
323
323
|
const css = chunk.source.replace(HASH_PLACEHOLDER_RE, "");
|
|
324
|
-
chunk.source = await replaceAsync(css, LAYER_PLACEHOLDER_RE, async (
|
|
324
|
+
chunk.source = await replaceAsync(css, LAYER_PLACEHOLDER_RE, async (_, __, layer) => {
|
|
325
325
|
replaced = true;
|
|
326
|
-
return await transformCSS(layer === LAYER_MARK_ALL ? result.getLayers(void 0, Array.from(vfsLayerMap.values())) : result.getLayer(layer) || "", `${chunk.fileName}.css
|
|
326
|
+
return await transformCSS(layer === LAYER_MARK_ALL ? result.getLayers(void 0, Array.from(vfsLayerMap.values())) : result.getLayer(layer) || "", `${chunk.fileName}.css`, options.dir);
|
|
327
327
|
});
|
|
328
328
|
}
|
|
329
329
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -196,15 +196,15 @@ function GlobalModeBuildPlugin({ uno, ready, extract, tokens, modules, filter, g
|
|
|
196
196
|
const vfsLayerMap = /* @__PURE__ */ new Map();
|
|
197
197
|
const layerImporterMap = /* @__PURE__ */ new Map();
|
|
198
198
|
let tasks = [];
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
async function transformCSS(css, id) {
|
|
199
|
+
const cssPostPlugins = /* @__PURE__ */ new Map();
|
|
200
|
+
const cssPlugins = /* @__PURE__ */ new Map();
|
|
201
|
+
async function transformCSS(css, id, dir) {
|
|
202
202
|
const {
|
|
203
203
|
postcss = true
|
|
204
204
|
} = await getConfig();
|
|
205
|
-
if (!
|
|
205
|
+
if (!cssPlugins.get(dir) || !postcss)
|
|
206
206
|
return css;
|
|
207
|
-
const result = await
|
|
207
|
+
const result = await cssPlugins.get(dir).transform(css, id);
|
|
208
208
|
if (!result)
|
|
209
209
|
return css;
|
|
210
210
|
if (typeof result === "string")
|
|
@@ -257,12 +257,12 @@ function GlobalModeBuildPlugin({ uno, ready, extract, tokens, modules, filter, g
|
|
|
257
257
|
}
|
|
258
258
|
},
|
|
259
259
|
async configResolved(config) {
|
|
260
|
-
|
|
261
|
-
|
|
260
|
+
cssPostPlugins.set(config.build.outDir, config.plugins.find((i) => i.name === "vite:css-post"));
|
|
261
|
+
cssPlugins.set(config.build.outDir, config.plugins.find((i) => i.name === "vite:css"));
|
|
262
262
|
await ready;
|
|
263
263
|
},
|
|
264
|
-
async renderChunk(_, chunk) {
|
|
265
|
-
if (!
|
|
264
|
+
async renderChunk(_, chunk, options) {
|
|
265
|
+
if (!cssPostPlugins.get(options.dir))
|
|
266
266
|
return null;
|
|
267
267
|
const chunks = Object.keys(chunk.modules).filter((i) => modules.has(i));
|
|
268
268
|
if (!chunks.length)
|
|
@@ -275,9 +275,9 @@ function GlobalModeBuildPlugin({ uno, ready, extract, tokens, modules, filter, g
|
|
|
275
275
|
return null;
|
|
276
276
|
if (!Object.keys(chunk.modules).some((i) => i.match(RESOLVED_ID_RE)))
|
|
277
277
|
return null;
|
|
278
|
-
css = await transformCSS(css, fakeCssId);
|
|
278
|
+
css = await transformCSS(css, fakeCssId, options.dir);
|
|
279
279
|
const hash = getHash(css);
|
|
280
|
-
await
|
|
280
|
+
await cssPostPlugins.get(options.dir).transform(getHashPlaceholder(hash), fakeCssId);
|
|
281
281
|
chunk.modules[fakeCssId] = {
|
|
282
282
|
code: null,
|
|
283
283
|
originalLength: 0,
|
|
@@ -294,7 +294,7 @@ function GlobalModeBuildPlugin({ uno, ready, extract, tokens, modules, filter, g
|
|
|
294
294
|
return command === "build" && !options.build?.ssr;
|
|
295
295
|
},
|
|
296
296
|
enforce: "post",
|
|
297
|
-
async generateBundle(
|
|
297
|
+
async generateBundle(options, bundle) {
|
|
298
298
|
const files = Object.keys(bundle);
|
|
299
299
|
const cssFiles = files.filter((i) => i.endsWith(".css"));
|
|
300
300
|
if (!cssFiles.length)
|
|
@@ -311,9 +311,9 @@ function GlobalModeBuildPlugin({ uno, ready, extract, tokens, modules, filter, g
|
|
|
311
311
|
const chunk = bundle[file];
|
|
312
312
|
if (chunk.type === "asset" && typeof chunk.source === "string") {
|
|
313
313
|
const css = chunk.source.replace(HASH_PLACEHOLDER_RE, "");
|
|
314
|
-
chunk.source = await replaceAsync(css, LAYER_PLACEHOLDER_RE, async (
|
|
314
|
+
chunk.source = await replaceAsync(css, LAYER_PLACEHOLDER_RE, async (_, __, layer) => {
|
|
315
315
|
replaced = true;
|
|
316
|
-
return await transformCSS(layer === LAYER_MARK_ALL ? result.getLayers(void 0, Array.from(vfsLayerMap.values())) : result.getLayer(layer) || "", `${chunk.fileName}.css
|
|
316
|
+
return await transformCSS(layer === LAYER_MARK_ALL ? result.getLayers(void 0, Array.from(vfsLayerMap.values())) : result.getLayer(layer) || "", `${chunk.fileName}.css`, options.dir);
|
|
317
317
|
});
|
|
318
318
|
}
|
|
319
319
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unocss/vite",
|
|
3
|
-
"version": "0.38.
|
|
3
|
+
"version": "0.38.1",
|
|
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.38.
|
|
47
|
-
"@unocss/core": "0.38.
|
|
48
|
-
"@unocss/inspector": "0.38.
|
|
49
|
-
"@unocss/scope": "0.38.
|
|
50
|
-
"@unocss/transformer-directives": "0.38.
|
|
46
|
+
"@unocss/config": "0.38.1",
|
|
47
|
+
"@unocss/core": "0.38.1",
|
|
48
|
+
"@unocss/inspector": "0.38.1",
|
|
49
|
+
"@unocss/scope": "0.38.1",
|
|
50
|
+
"@unocss/transformer-directives": "0.38.1",
|
|
51
51
|
"magic-string": "^0.26.2"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@unocss/shared-integration": "0.38.
|
|
54
|
+
"@unocss/shared-integration": "0.38.1",
|
|
55
55
|
"vite": "^2.9.9"
|
|
56
56
|
},
|
|
57
57
|
"scripts": {
|