@unocss/vite 0.33.1 → 0.33.5
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 +18 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +18 -2
- package/package.json +9 -9
package/dist/index.cjs
CHANGED
|
@@ -195,6 +195,7 @@ function ChunkModeBuildPlugin({ uno, filter }) {
|
|
|
195
195
|
|
|
196
196
|
function GlobalModeBuildPlugin({ uno, ready, extract, tokens, modules, filter, getConfig }) {
|
|
197
197
|
const vfsLayerMap = /* @__PURE__ */ new Map();
|
|
198
|
+
const layerImporterMap = /* @__PURE__ */ new Map();
|
|
198
199
|
let tasks = [];
|
|
199
200
|
let cssPostPlugin;
|
|
200
201
|
let cssPlugin;
|
|
@@ -221,7 +222,6 @@ function GlobalModeBuildPlugin({ uno, ready, extract, tokens, modules, filter, g
|
|
|
221
222
|
enforce: "pre",
|
|
222
223
|
buildStart() {
|
|
223
224
|
tasks = [];
|
|
224
|
-
vfsLayerMap.clear();
|
|
225
225
|
},
|
|
226
226
|
transform(code, id) {
|
|
227
227
|
if (filter(code, id))
|
|
@@ -234,10 +234,12 @@ function GlobalModeBuildPlugin({ uno, ready, extract, tokens, modules, filter, g
|
|
|
234
234
|
tasks.push(extract(code, filename));
|
|
235
235
|
}
|
|
236
236
|
},
|
|
237
|
-
resolveId(id) {
|
|
237
|
+
resolveId(id, importer) {
|
|
238
238
|
const entry = resolveId(id);
|
|
239
239
|
if (entry) {
|
|
240
240
|
vfsLayerMap.set(entry.id, entry.layer);
|
|
241
|
+
if (importer)
|
|
242
|
+
layerImporterMap.set(importer, entry.id);
|
|
241
243
|
return entry.id;
|
|
242
244
|
}
|
|
243
245
|
},
|
|
@@ -246,6 +248,15 @@ function GlobalModeBuildPlugin({ uno, ready, extract, tokens, modules, filter, g
|
|
|
246
248
|
if (layer)
|
|
247
249
|
return getLayerPlaceholder(layer);
|
|
248
250
|
},
|
|
251
|
+
moduleParsed({ id, importedIds }) {
|
|
252
|
+
if (!layerImporterMap.has(id))
|
|
253
|
+
return;
|
|
254
|
+
const layerKey = layerImporterMap.get(id);
|
|
255
|
+
if (!importedIds.includes(layerKey)) {
|
|
256
|
+
layerImporterMap.delete(id);
|
|
257
|
+
vfsLayerMap.delete(layerKey);
|
|
258
|
+
}
|
|
259
|
+
},
|
|
249
260
|
async configResolved(config) {
|
|
250
261
|
cssPostPlugin = config.plugins.find((i) => i.name === "vite:css-post");
|
|
251
262
|
cssPlugin = config.plugins.find((i) => i.name === "vite:css");
|
|
@@ -289,6 +300,11 @@ function GlobalModeBuildPlugin({ uno, ready, extract, tokens, modules, filter, g
|
|
|
289
300
|
const cssFiles = files.filter((i) => i.endsWith(".css"));
|
|
290
301
|
if (!cssFiles.length)
|
|
291
302
|
return;
|
|
303
|
+
if (!vfsLayerMap.size) {
|
|
304
|
+
const msg = "[unocss] entry module not found, have you add `import 'uno.css'` in your main entry?";
|
|
305
|
+
this.warn(msg);
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
292
308
|
await Promise.all(tasks);
|
|
293
309
|
const result = await uno.generate(tokens, { minify: true });
|
|
294
310
|
let replaced = false;
|
package/dist/index.d.ts
CHANGED
|
@@ -52,6 +52,6 @@ declare function VueScopedPlugin({ uno, ready }: UnocssPluginContext): Plugin;
|
|
|
52
52
|
declare function SvelteScopedPlugin({ uno, ready }: UnocssPluginContext): Plugin;
|
|
53
53
|
|
|
54
54
|
declare function defineConfig<Theme extends {}>(config: VitePluginConfig<Theme>): VitePluginConfig<Theme>;
|
|
55
|
-
declare function UnocssPlugin(configOrPath?: VitePluginConfig | string, defaults?: UserConfigDefaults): Plugin[];
|
|
55
|
+
declare function UnocssPlugin<Theme extends {}>(configOrPath?: VitePluginConfig<Theme> | string, defaults?: UserConfigDefaults): Plugin[];
|
|
56
56
|
|
|
57
57
|
export { ChunkModeBuildPlugin, GlobalModeBuildPlugin, GlobalModeDevPlugin, GlobalModePlugin, PerModuleModePlugin, SvelteScopedPlugin, VitePluginConfig, VueScopedPlugin, UnocssPlugin as default, defineConfig };
|
package/dist/index.mjs
CHANGED
|
@@ -185,6 +185,7 @@ function ChunkModeBuildPlugin({ uno, filter }) {
|
|
|
185
185
|
|
|
186
186
|
function GlobalModeBuildPlugin({ uno, ready, extract, tokens, modules, filter, getConfig }) {
|
|
187
187
|
const vfsLayerMap = /* @__PURE__ */ new Map();
|
|
188
|
+
const layerImporterMap = /* @__PURE__ */ new Map();
|
|
188
189
|
let tasks = [];
|
|
189
190
|
let cssPostPlugin;
|
|
190
191
|
let cssPlugin;
|
|
@@ -211,7 +212,6 @@ function GlobalModeBuildPlugin({ uno, ready, extract, tokens, modules, filter, g
|
|
|
211
212
|
enforce: "pre",
|
|
212
213
|
buildStart() {
|
|
213
214
|
tasks = [];
|
|
214
|
-
vfsLayerMap.clear();
|
|
215
215
|
},
|
|
216
216
|
transform(code, id) {
|
|
217
217
|
if (filter(code, id))
|
|
@@ -224,10 +224,12 @@ function GlobalModeBuildPlugin({ uno, ready, extract, tokens, modules, filter, g
|
|
|
224
224
|
tasks.push(extract(code, filename));
|
|
225
225
|
}
|
|
226
226
|
},
|
|
227
|
-
resolveId(id) {
|
|
227
|
+
resolveId(id, importer) {
|
|
228
228
|
const entry = resolveId(id);
|
|
229
229
|
if (entry) {
|
|
230
230
|
vfsLayerMap.set(entry.id, entry.layer);
|
|
231
|
+
if (importer)
|
|
232
|
+
layerImporterMap.set(importer, entry.id);
|
|
231
233
|
return entry.id;
|
|
232
234
|
}
|
|
233
235
|
},
|
|
@@ -236,6 +238,15 @@ function GlobalModeBuildPlugin({ uno, ready, extract, tokens, modules, filter, g
|
|
|
236
238
|
if (layer)
|
|
237
239
|
return getLayerPlaceholder(layer);
|
|
238
240
|
},
|
|
241
|
+
moduleParsed({ id, importedIds }) {
|
|
242
|
+
if (!layerImporterMap.has(id))
|
|
243
|
+
return;
|
|
244
|
+
const layerKey = layerImporterMap.get(id);
|
|
245
|
+
if (!importedIds.includes(layerKey)) {
|
|
246
|
+
layerImporterMap.delete(id);
|
|
247
|
+
vfsLayerMap.delete(layerKey);
|
|
248
|
+
}
|
|
249
|
+
},
|
|
239
250
|
async configResolved(config) {
|
|
240
251
|
cssPostPlugin = config.plugins.find((i) => i.name === "vite:css-post");
|
|
241
252
|
cssPlugin = config.plugins.find((i) => i.name === "vite:css");
|
|
@@ -279,6 +290,11 @@ function GlobalModeBuildPlugin({ uno, ready, extract, tokens, modules, filter, g
|
|
|
279
290
|
const cssFiles = files.filter((i) => i.endsWith(".css"));
|
|
280
291
|
if (!cssFiles.length)
|
|
281
292
|
return;
|
|
293
|
+
if (!vfsLayerMap.size) {
|
|
294
|
+
const msg = "[unocss] entry module not found, have you add `import 'uno.css'` in your main entry?";
|
|
295
|
+
this.warn(msg);
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
282
298
|
await Promise.all(tasks);
|
|
283
299
|
const result = await uno.generate(tokens, { minify: true });
|
|
284
300
|
let replaced = false;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unocss/vite",
|
|
3
|
-
"version": "0.33.
|
|
3
|
+
"version": "0.33.5",
|
|
4
4
|
"description": "The Vite plugin for UnoCSS",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"unocss",
|
|
@@ -43,16 +43,16 @@
|
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@rollup/pluginutils": "^4.2.1",
|
|
46
|
-
"@unocss/config": "0.33.
|
|
47
|
-
"@unocss/core": "0.33.
|
|
48
|
-
"@unocss/inspector": "0.33.
|
|
49
|
-
"@unocss/scope": "0.33.
|
|
50
|
-
"@unocss/transformer-directives": "0.33.
|
|
51
|
-
"magic-string": "^0.26.
|
|
46
|
+
"@unocss/config": "0.33.5",
|
|
47
|
+
"@unocss/core": "0.33.5",
|
|
48
|
+
"@unocss/inspector": "0.33.5",
|
|
49
|
+
"@unocss/scope": "0.33.5",
|
|
50
|
+
"@unocss/transformer-directives": "0.33.5",
|
|
51
|
+
"magic-string": "^0.26.2"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@unocss/shared-integration": "0.33.
|
|
55
|
-
"vite": "^2.9.
|
|
54
|
+
"@unocss/shared-integration": "0.33.5",
|
|
55
|
+
"vite": "^2.9.9"
|
|
56
56
|
},
|
|
57
57
|
"scripts": {
|
|
58
58
|
"build": "unbuild",
|