@unocss/vite 0.53.4 → 0.53.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 +7 -4
- package/dist/index.d.ts +3 -3
- package/dist/index.mjs +7 -4
- package/package.json +10 -10
package/dist/index.cjs
CHANGED
|
@@ -521,8 +521,9 @@ function GlobalModeBuildPlugin(ctx) {
|
|
|
521
521
|
return null;
|
|
522
522
|
}
|
|
523
523
|
const result = await generateAll();
|
|
524
|
+
const mappedVfsLayer = Array.from(vfsLayers).map((layer) => layer === LAYER_MARK_ALL ? layer : layer.replace(/^_/, ""));
|
|
524
525
|
const cssWithLayers = Array.from(vfsLayers).map(
|
|
525
|
-
(layer) => `#--unocss-layer-start--${layer}--{start:${layer}} ${layer === LAYER_MARK_ALL ? result.getLayers(void 0,
|
|
526
|
+
(layer) => `#--unocss-layer-start--${layer}--{start:${layer}} ${layer === LAYER_MARK_ALL ? result.getLayers(void 0, mappedVfsLayer) : result.getLayer(layer.replace(/^_/, "")) || ""} #--unocss-layer-end--${layer}--{end:${layer}}`
|
|
526
527
|
).join("");
|
|
527
528
|
const fakeCssId = `${viteConfig.root}/${chunk.fileName}-unocss-hash.css`;
|
|
528
529
|
const css = await applyCssTransform(cssWithLayers, fakeCssId, options.dir, this);
|
|
@@ -1061,7 +1062,7 @@ const MODULES_MAP = {
|
|
|
1061
1062
|
[DEVTOOLS_MODULE_ID]: DEVTOOLS_PATH,
|
|
1062
1063
|
[MOCK_CLASSES_MODULE_ID]: MOCK_CLASSES_PATH
|
|
1063
1064
|
};
|
|
1064
|
-
const
|
|
1065
|
+
const BASE_POST_PATH = "/@unocss-devtools-update";
|
|
1065
1066
|
function getBodyJson(req) {
|
|
1066
1067
|
return new Promise((resolve2, reject) => {
|
|
1067
1068
|
let body = "";
|
|
@@ -1082,6 +1083,7 @@ function createDevtoolsPlugin(ctx) {
|
|
|
1082
1083
|
let clientCode = "";
|
|
1083
1084
|
let devtoolTimer;
|
|
1084
1085
|
let lastUpdate = Date.now();
|
|
1086
|
+
let postPath = BASE_POST_PATH;
|
|
1085
1087
|
function toClass(name) {
|
|
1086
1088
|
return `${core.toEscapedSelector(name)}{}`;
|
|
1087
1089
|
}
|
|
@@ -1122,11 +1124,12 @@ function createDevtoolsPlugin(ctx) {
|
|
|
1122
1124
|
name: "unocss:devtools",
|
|
1123
1125
|
configResolved(_config) {
|
|
1124
1126
|
config = _config;
|
|
1127
|
+
postPath = `${config.base?.replace(/\/$/, "") ?? ""}${BASE_POST_PATH}`;
|
|
1125
1128
|
},
|
|
1126
1129
|
configureServer(_server) {
|
|
1127
1130
|
server = _server;
|
|
1128
1131
|
server.middlewares.use(async (req, res, next) => {
|
|
1129
|
-
if (req.url !==
|
|
1132
|
+
if (req.url !== postPath)
|
|
1130
1133
|
return next();
|
|
1131
1134
|
try {
|
|
1132
1135
|
const data = await getBodyJson(req);
|
|
@@ -1163,7 +1166,7 @@ function createDevtoolsPlugin(ctx) {
|
|
|
1163
1166
|
await fs__default$1.promises.readFile(node_path.resolve(_dirname, "client.mjs"), "utf-8"),
|
|
1164
1167
|
`import('${MOCK_CLASSES_MODULE_ID}')`,
|
|
1165
1168
|
`import('${DEVTOOLS_CSS_PATH}')`
|
|
1166
|
-
].join("\n").replace("__POST_PATH__",
|
|
1169
|
+
].join("\n").replace("__POST_PATH__", `${config.server?.origin ?? ""}${postPath}`);
|
|
1167
1170
|
}
|
|
1168
1171
|
return config.command === "build" ? "" : clientCode;
|
|
1169
1172
|
} else if (id === MOCK_CLASSES_PATH) {
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import * as vite from 'vite';
|
|
|
2
2
|
import { Plugin } from 'vite';
|
|
3
3
|
import { UserConfig, UnocssPluginContext, UserConfigDefaults } from '@unocss/core';
|
|
4
4
|
|
|
5
|
-
interface VitePluginConfig<Theme extends
|
|
5
|
+
interface VitePluginConfig<Theme extends object = object> extends UserConfig<Theme> {
|
|
6
6
|
/**
|
|
7
7
|
* Enable UnoCSS inspector
|
|
8
8
|
*
|
|
@@ -59,7 +59,7 @@ declare function PerModuleModePlugin({ uno, filter }: UnocssPluginContext): Plug
|
|
|
59
59
|
|
|
60
60
|
declare function VueScopedPlugin({ uno, ready }: UnocssPluginContext): Plugin;
|
|
61
61
|
|
|
62
|
-
declare function defineConfig<Theme extends
|
|
63
|
-
declare function UnocssPlugin<Theme extends
|
|
62
|
+
declare function defineConfig<Theme extends object>(config: VitePluginConfig<Theme>): VitePluginConfig<Theme>;
|
|
63
|
+
declare function UnocssPlugin<Theme extends object>(configOrPath?: VitePluginConfig<Theme> | string, defaults?: UserConfigDefaults): Plugin[];
|
|
64
64
|
|
|
65
65
|
export { ChunkModeBuildPlugin, GlobalModeBuildPlugin, GlobalModeDevPlugin, GlobalModePlugin, PerModuleModePlugin, VitePluginConfig, VueScopedPlugin, UnocssPlugin as default, defineConfig };
|
package/dist/index.mjs
CHANGED
|
@@ -508,8 +508,9 @@ function GlobalModeBuildPlugin(ctx) {
|
|
|
508
508
|
return null;
|
|
509
509
|
}
|
|
510
510
|
const result = await generateAll();
|
|
511
|
+
const mappedVfsLayer = Array.from(vfsLayers).map((layer) => layer === LAYER_MARK_ALL ? layer : layer.replace(/^_/, ""));
|
|
511
512
|
const cssWithLayers = Array.from(vfsLayers).map(
|
|
512
|
-
(layer) => `#--unocss-layer-start--${layer}--{start:${layer}} ${layer === LAYER_MARK_ALL ? result.getLayers(void 0,
|
|
513
|
+
(layer) => `#--unocss-layer-start--${layer}--{start:${layer}} ${layer === LAYER_MARK_ALL ? result.getLayers(void 0, mappedVfsLayer) : result.getLayer(layer.replace(/^_/, "")) || ""} #--unocss-layer-end--${layer}--{end:${layer}}`
|
|
513
514
|
).join("");
|
|
514
515
|
const fakeCssId = `${viteConfig.root}/${chunk.fileName}-unocss-hash.css`;
|
|
515
516
|
const css = await applyCssTransform(cssWithLayers, fakeCssId, options.dir, this);
|
|
@@ -1048,7 +1049,7 @@ const MODULES_MAP = {
|
|
|
1048
1049
|
[DEVTOOLS_MODULE_ID]: DEVTOOLS_PATH,
|
|
1049
1050
|
[MOCK_CLASSES_MODULE_ID]: MOCK_CLASSES_PATH
|
|
1050
1051
|
};
|
|
1051
|
-
const
|
|
1052
|
+
const BASE_POST_PATH = "/@unocss-devtools-update";
|
|
1052
1053
|
function getBodyJson(req) {
|
|
1053
1054
|
return new Promise((resolve2, reject) => {
|
|
1054
1055
|
let body = "";
|
|
@@ -1069,6 +1070,7 @@ function createDevtoolsPlugin(ctx) {
|
|
|
1069
1070
|
let clientCode = "";
|
|
1070
1071
|
let devtoolTimer;
|
|
1071
1072
|
let lastUpdate = Date.now();
|
|
1073
|
+
let postPath = BASE_POST_PATH;
|
|
1072
1074
|
function toClass(name) {
|
|
1073
1075
|
return `${toEscapedSelector(name)}{}`;
|
|
1074
1076
|
}
|
|
@@ -1109,11 +1111,12 @@ function createDevtoolsPlugin(ctx) {
|
|
|
1109
1111
|
name: "unocss:devtools",
|
|
1110
1112
|
configResolved(_config) {
|
|
1111
1113
|
config = _config;
|
|
1114
|
+
postPath = `${config.base?.replace(/\/$/, "") ?? ""}${BASE_POST_PATH}`;
|
|
1112
1115
|
},
|
|
1113
1116
|
configureServer(_server) {
|
|
1114
1117
|
server = _server;
|
|
1115
1118
|
server.middlewares.use(async (req, res, next) => {
|
|
1116
|
-
if (req.url !==
|
|
1119
|
+
if (req.url !== postPath)
|
|
1117
1120
|
return next();
|
|
1118
1121
|
try {
|
|
1119
1122
|
const data = await getBodyJson(req);
|
|
@@ -1150,7 +1153,7 @@ function createDevtoolsPlugin(ctx) {
|
|
|
1150
1153
|
await fs$1.promises.readFile(resolve(_dirname, "client.mjs"), "utf-8"),
|
|
1151
1154
|
`import('${MOCK_CLASSES_MODULE_ID}')`,
|
|
1152
1155
|
`import('${DEVTOOLS_CSS_PATH}')`
|
|
1153
|
-
].join("\n").replace("__POST_PATH__",
|
|
1156
|
+
].join("\n").replace("__POST_PATH__", `${config.server?.origin ?? ""}${postPath}`);
|
|
1154
1157
|
}
|
|
1155
1158
|
return config.command === "build" ? "" : clientCode;
|
|
1156
1159
|
} else if (id === MOCK_CLASSES_PATH) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unocss/vite",
|
|
3
|
-
"version": "0.53.
|
|
3
|
+
"version": "0.53.5",
|
|
4
4
|
"description": "The Vite plugin for UnoCSS",
|
|
5
5
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -45,17 +45,17 @@
|
|
|
45
45
|
"@ampproject/remapping": "^2.2.1",
|
|
46
46
|
"@rollup/pluginutils": "^5.0.2",
|
|
47
47
|
"chokidar": "^3.5.3",
|
|
48
|
-
"fast-glob": "^3.
|
|
49
|
-
"magic-string": "^0.30.
|
|
50
|
-
"@unocss/config": "0.53.
|
|
51
|
-
"@unocss/core": "0.53.
|
|
52
|
-
"@unocss/inspector": "0.53.
|
|
53
|
-
"@unocss/scope": "0.53.
|
|
54
|
-
"@unocss/transformer-directives": "0.53.
|
|
48
|
+
"fast-glob": "^3.3.0",
|
|
49
|
+
"magic-string": "^0.30.1",
|
|
50
|
+
"@unocss/config": "0.53.5",
|
|
51
|
+
"@unocss/core": "0.53.5",
|
|
52
|
+
"@unocss/inspector": "0.53.5",
|
|
53
|
+
"@unocss/scope": "0.53.5",
|
|
54
|
+
"@unocss/transformer-directives": "0.53.5"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"vite": "^4.
|
|
58
|
-
"@unocss/shared-integration": "0.53.
|
|
57
|
+
"vite": "^4.4.2",
|
|
58
|
+
"@unocss/shared-integration": "0.53.5"
|
|
59
59
|
},
|
|
60
60
|
"scripts": {
|
|
61
61
|
"build": "unbuild",
|