@unocss/vite 0.54.2 → 0.55.0
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 +38 -21
- package/dist/index.d.ts +5 -1
- package/dist/index.mjs +38 -21
- package/package.json +11 -11
package/dist/index.cjs
CHANGED
|
@@ -814,22 +814,36 @@ function PerModuleModePlugin({ uno, filter }) {
|
|
|
814
814
|
{
|
|
815
815
|
name: "unocss:module-scope:pre",
|
|
816
816
|
enforce: "pre",
|
|
817
|
+
resolveId(id) {
|
|
818
|
+
const entry = resolveId(id);
|
|
819
|
+
if (entry)
|
|
820
|
+
return entry;
|
|
821
|
+
},
|
|
822
|
+
async load(id) {
|
|
823
|
+
const layer = resolveLayer(getPath(id));
|
|
824
|
+
if (!layer)
|
|
825
|
+
return null;
|
|
826
|
+
const { css } = await uno.generate("", { preflights: true });
|
|
827
|
+
if (!css)
|
|
828
|
+
return null;
|
|
829
|
+
return {
|
|
830
|
+
code: css,
|
|
831
|
+
map: null
|
|
832
|
+
};
|
|
833
|
+
},
|
|
817
834
|
async transform(code, id) {
|
|
818
835
|
if (!filter(code, id))
|
|
819
836
|
return;
|
|
820
837
|
const hash = getHash(id);
|
|
821
|
-
const
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
});
|
|
825
|
-
if (!css)
|
|
838
|
+
const hasScope = code.match(SCOPE_IMPORT_RE);
|
|
839
|
+
const { css } = await uno.generate(code, { id, scope: hasScope ? `.${hash}` : void 0, preflights: false });
|
|
840
|
+
if (!css && !hasScope)
|
|
826
841
|
return null;
|
|
842
|
+
if (hasScope)
|
|
843
|
+
code = code.replace(SCOPE_IMPORT_RE, ` from 'data:text/javascript;base64,${node_buffer.Buffer.from(`export default () => "${hash}"`).toString("base64")}'`);
|
|
827
844
|
moduleMap.set(hash, [id, css]);
|
|
828
845
|
invalidate(hash);
|
|
829
|
-
return
|
|
830
|
-
code: `import "${VIRTUAL_PREFIX}${hash}.css";${code}`,
|
|
831
|
-
map: null
|
|
832
|
-
};
|
|
846
|
+
return null;
|
|
833
847
|
}
|
|
834
848
|
},
|
|
835
849
|
{
|
|
@@ -842,18 +856,14 @@ function PerModuleModePlugin({ uno, filter }) {
|
|
|
842
856
|
if (!filter(code, id))
|
|
843
857
|
return;
|
|
844
858
|
const hash = getHash(id);
|
|
845
|
-
const hasScope = code.match(SCOPE_IMPORT_RE);
|
|
846
|
-
const { css } = await uno.generate(code, { id, scope: hasScope ? `.${hash}` : void 0, preflights: false });
|
|
847
|
-
if (!css && !hasScope)
|
|
848
|
-
return null;
|
|
849
|
-
if (hasScope)
|
|
850
|
-
code = code.replace(SCOPE_IMPORT_RE, ` from 'data:text/javascript;base64,${node_buffer.Buffer.from(`export default () => "${hash}"`).toString("base64")}'`);
|
|
851
|
-
moduleMap.set(hash, [id, css]);
|
|
852
859
|
invalidate(hash);
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
860
|
+
const module = moduleMap.get(hash) || [];
|
|
861
|
+
if (module.length) {
|
|
862
|
+
return {
|
|
863
|
+
code: `import "${VIRTUAL_PREFIX}${hash}.css";${code}`,
|
|
864
|
+
map: null
|
|
865
|
+
};
|
|
866
|
+
}
|
|
857
867
|
},
|
|
858
868
|
resolveId(id) {
|
|
859
869
|
return id.startsWith(VIRTUAL_PREFIX) ? id : null;
|
|
@@ -1192,7 +1202,14 @@ function UnocssPlugin(configOrPath, defaults = {}) {
|
|
|
1192
1202
|
const plugins = [
|
|
1193
1203
|
ConfigHMRPlugin(ctx),
|
|
1194
1204
|
...createTransformerPlugins(ctx),
|
|
1195
|
-
...createDevtoolsPlugin(ctx)
|
|
1205
|
+
...createDevtoolsPlugin(ctx),
|
|
1206
|
+
{
|
|
1207
|
+
name: "unocss:api",
|
|
1208
|
+
api: {
|
|
1209
|
+
getContext: () => ctx,
|
|
1210
|
+
getMode: () => mode
|
|
1211
|
+
}
|
|
1212
|
+
}
|
|
1196
1213
|
];
|
|
1197
1214
|
if (inlineConfig.inspector !== false)
|
|
1198
1215
|
plugins.push(UnocssInspector__default(ctx));
|
package/dist/index.d.ts
CHANGED
|
@@ -60,6 +60,10 @@ declare function PerModuleModePlugin({ uno, filter }: UnocssPluginContext): Plug
|
|
|
60
60
|
declare function VueScopedPlugin({ uno, ready }: UnocssPluginContext): Plugin;
|
|
61
61
|
|
|
62
62
|
declare function defineConfig<Theme extends object>(config: VitePluginConfig<Theme>): VitePluginConfig<Theme>;
|
|
63
|
+
interface UnocssVitePluginAPI {
|
|
64
|
+
getContext(): UnocssPluginContext<VitePluginConfig>;
|
|
65
|
+
getMode(): VitePluginConfig['mode'];
|
|
66
|
+
}
|
|
63
67
|
declare function UnocssPlugin<Theme extends object>(configOrPath?: VitePluginConfig<Theme> | string, defaults?: UserConfigDefaults): Plugin[];
|
|
64
68
|
|
|
65
|
-
export { ChunkModeBuildPlugin, GlobalModeBuildPlugin, GlobalModeDevPlugin, GlobalModePlugin, PerModuleModePlugin, VitePluginConfig, VueScopedPlugin, UnocssPlugin as default, defineConfig };
|
|
69
|
+
export { ChunkModeBuildPlugin, GlobalModeBuildPlugin, GlobalModeDevPlugin, GlobalModePlugin, PerModuleModePlugin, UnocssVitePluginAPI, VitePluginConfig, VueScopedPlugin, UnocssPlugin as default, defineConfig };
|
package/dist/index.mjs
CHANGED
|
@@ -800,22 +800,36 @@ function PerModuleModePlugin({ uno, filter }) {
|
|
|
800
800
|
{
|
|
801
801
|
name: "unocss:module-scope:pre",
|
|
802
802
|
enforce: "pre",
|
|
803
|
+
resolveId(id) {
|
|
804
|
+
const entry = resolveId(id);
|
|
805
|
+
if (entry)
|
|
806
|
+
return entry;
|
|
807
|
+
},
|
|
808
|
+
async load(id) {
|
|
809
|
+
const layer = resolveLayer(getPath(id));
|
|
810
|
+
if (!layer)
|
|
811
|
+
return null;
|
|
812
|
+
const { css } = await uno.generate("", { preflights: true });
|
|
813
|
+
if (!css)
|
|
814
|
+
return null;
|
|
815
|
+
return {
|
|
816
|
+
code: css,
|
|
817
|
+
map: null
|
|
818
|
+
};
|
|
819
|
+
},
|
|
803
820
|
async transform(code, id) {
|
|
804
821
|
if (!filter(code, id))
|
|
805
822
|
return;
|
|
806
823
|
const hash = getHash(id);
|
|
807
|
-
const
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
});
|
|
811
|
-
if (!css)
|
|
824
|
+
const hasScope = code.match(SCOPE_IMPORT_RE);
|
|
825
|
+
const { css } = await uno.generate(code, { id, scope: hasScope ? `.${hash}` : void 0, preflights: false });
|
|
826
|
+
if (!css && !hasScope)
|
|
812
827
|
return null;
|
|
828
|
+
if (hasScope)
|
|
829
|
+
code = code.replace(SCOPE_IMPORT_RE, ` from 'data:text/javascript;base64,${Buffer.from(`export default () => "${hash}"`).toString("base64")}'`);
|
|
813
830
|
moduleMap.set(hash, [id, css]);
|
|
814
831
|
invalidate(hash);
|
|
815
|
-
return
|
|
816
|
-
code: `import "${VIRTUAL_PREFIX}${hash}.css";${code}`,
|
|
817
|
-
map: null
|
|
818
|
-
};
|
|
832
|
+
return null;
|
|
819
833
|
}
|
|
820
834
|
},
|
|
821
835
|
{
|
|
@@ -828,18 +842,14 @@ function PerModuleModePlugin({ uno, filter }) {
|
|
|
828
842
|
if (!filter(code, id))
|
|
829
843
|
return;
|
|
830
844
|
const hash = getHash(id);
|
|
831
|
-
const hasScope = code.match(SCOPE_IMPORT_RE);
|
|
832
|
-
const { css } = await uno.generate(code, { id, scope: hasScope ? `.${hash}` : void 0, preflights: false });
|
|
833
|
-
if (!css && !hasScope)
|
|
834
|
-
return null;
|
|
835
|
-
if (hasScope)
|
|
836
|
-
code = code.replace(SCOPE_IMPORT_RE, ` from 'data:text/javascript;base64,${Buffer.from(`export default () => "${hash}"`).toString("base64")}'`);
|
|
837
|
-
moduleMap.set(hash, [id, css]);
|
|
838
845
|
invalidate(hash);
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
846
|
+
const module = moduleMap.get(hash) || [];
|
|
847
|
+
if (module.length) {
|
|
848
|
+
return {
|
|
849
|
+
code: `import "${VIRTUAL_PREFIX}${hash}.css";${code}`,
|
|
850
|
+
map: null
|
|
851
|
+
};
|
|
852
|
+
}
|
|
843
853
|
},
|
|
844
854
|
resolveId(id) {
|
|
845
855
|
return id.startsWith(VIRTUAL_PREFIX) ? id : null;
|
|
@@ -1178,7 +1188,14 @@ function UnocssPlugin(configOrPath, defaults = {}) {
|
|
|
1178
1188
|
const plugins = [
|
|
1179
1189
|
ConfigHMRPlugin(ctx),
|
|
1180
1190
|
...createTransformerPlugins(ctx),
|
|
1181
|
-
...createDevtoolsPlugin(ctx)
|
|
1191
|
+
...createDevtoolsPlugin(ctx),
|
|
1192
|
+
{
|
|
1193
|
+
name: "unocss:api",
|
|
1194
|
+
api: {
|
|
1195
|
+
getContext: () => ctx,
|
|
1196
|
+
getMode: () => mode
|
|
1197
|
+
}
|
|
1198
|
+
}
|
|
1182
1199
|
];
|
|
1183
1200
|
if (inlineConfig.inspector !== false)
|
|
1184
1201
|
plugins.push(UnocssInspector(ctx));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unocss/vite",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.55.0",
|
|
4
4
|
"description": "The Vite plugin for UnoCSS",
|
|
5
5
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -23,13 +23,13 @@
|
|
|
23
23
|
"exports": {
|
|
24
24
|
".": {
|
|
25
25
|
"types": "./dist/index.d.ts",
|
|
26
|
-
"
|
|
27
|
-
"
|
|
26
|
+
"import": "./dist/index.mjs",
|
|
27
|
+
"require": "./dist/index.cjs"
|
|
28
28
|
},
|
|
29
29
|
"./client": {
|
|
30
30
|
"types": "./dist/client.d.ts",
|
|
31
|
-
"
|
|
32
|
-
"
|
|
31
|
+
"import": "./dist/client.mjs",
|
|
32
|
+
"require": "./dist/client.cjs"
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
35
|
"main": "dist/index.cjs",
|
|
@@ -47,15 +47,15 @@
|
|
|
47
47
|
"chokidar": "^3.5.3",
|
|
48
48
|
"fast-glob": "^3.3.1",
|
|
49
49
|
"magic-string": "^0.30.2",
|
|
50
|
-
"@unocss/config": "0.
|
|
51
|
-
"@unocss/core": "0.
|
|
52
|
-
"@unocss/inspector": "0.
|
|
53
|
-
"@unocss/scope": "0.
|
|
54
|
-
"@unocss/transformer-directives": "0.
|
|
50
|
+
"@unocss/config": "0.55.0",
|
|
51
|
+
"@unocss/core": "0.55.0",
|
|
52
|
+
"@unocss/inspector": "0.55.0",
|
|
53
|
+
"@unocss/scope": "0.55.0",
|
|
54
|
+
"@unocss/transformer-directives": "0.55.0"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"vite": "^4.4.9",
|
|
58
|
-
"@unocss/shared-integration": "0.
|
|
58
|
+
"@unocss/shared-integration": "0.55.0"
|
|
59
59
|
},
|
|
60
60
|
"scripts": {
|
|
61
61
|
"build": "unbuild",
|