@unocss/vite 0.31.9 → 0.31.13
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 +20 -9
- package/dist/index.mjs +21 -10
- package/package.json +6 -6
package/dist/index.cjs
CHANGED
|
@@ -54,16 +54,16 @@ const CSS_PLACEHOLDER = "@unocss-placeholder";
|
|
|
54
54
|
|
|
55
55
|
function createContext(configOrPath, defaults = {}, extraConfigSources = [], resolveConfigResult = () => {
|
|
56
56
|
}) {
|
|
57
|
-
|
|
57
|
+
let root = process.cwd();
|
|
58
58
|
let rawConfig = {};
|
|
59
59
|
const uno = core.createGenerator(rawConfig, defaults);
|
|
60
60
|
let rollupFilter = pluginutils.createFilter(defaultInclude, defaultExclude);
|
|
61
61
|
const invalidations = [];
|
|
62
62
|
const modules = new core.BetterMap();
|
|
63
63
|
const tokens = /* @__PURE__ */ new Set();
|
|
64
|
-
|
|
64
|
+
let ready = reloadConfig();
|
|
65
65
|
async function reloadConfig() {
|
|
66
|
-
const result = await loadConfig();
|
|
66
|
+
const result = await config.loadConfig(root, configOrPath, extraConfigSources);
|
|
67
67
|
resolveConfigResult(result);
|
|
68
68
|
rawConfig = result.config;
|
|
69
69
|
uno.setConfig(rawConfig);
|
|
@@ -74,6 +74,13 @@ function createContext(configOrPath, defaults = {}, extraConfigSources = [], res
|
|
|
74
74
|
invalidate();
|
|
75
75
|
return result;
|
|
76
76
|
}
|
|
77
|
+
async function updateRoot(newRoot) {
|
|
78
|
+
if (newRoot !== root) {
|
|
79
|
+
root = newRoot;
|
|
80
|
+
ready = reloadConfig();
|
|
81
|
+
}
|
|
82
|
+
return await ready;
|
|
83
|
+
}
|
|
77
84
|
function invalidate() {
|
|
78
85
|
invalidations.forEach((cb) => cb());
|
|
79
86
|
}
|
|
@@ -93,7 +100,9 @@ function createContext(configOrPath, defaults = {}, extraConfigSources = [], res
|
|
|
93
100
|
return rawConfig;
|
|
94
101
|
}
|
|
95
102
|
return {
|
|
96
|
-
ready
|
|
103
|
+
get ready() {
|
|
104
|
+
return ready;
|
|
105
|
+
},
|
|
97
106
|
tokens,
|
|
98
107
|
modules,
|
|
99
108
|
invalidate,
|
|
@@ -104,7 +113,9 @@ function createContext(configOrPath, defaults = {}, extraConfigSources = [], res
|
|
|
104
113
|
reloadConfig,
|
|
105
114
|
uno,
|
|
106
115
|
extract,
|
|
107
|
-
getConfig
|
|
116
|
+
getConfig,
|
|
117
|
+
root,
|
|
118
|
+
updateRoot
|
|
108
119
|
};
|
|
109
120
|
}
|
|
110
121
|
|
|
@@ -621,8 +632,8 @@ function ConfigHMRPlugin(ctx) {
|
|
|
621
632
|
const { ready, uno } = ctx;
|
|
622
633
|
return {
|
|
623
634
|
name: "unocss:config",
|
|
624
|
-
async configResolved() {
|
|
625
|
-
await
|
|
635
|
+
async configResolved(config) {
|
|
636
|
+
await ctx.updateRoot(config.root);
|
|
626
637
|
},
|
|
627
638
|
async configureServer(server) {
|
|
628
639
|
uno.config.envMode = "dev";
|
|
@@ -833,9 +844,9 @@ function UnocssPlugin(configOrPath, defaults = {}) {
|
|
|
833
844
|
const inlineConfig = configOrPath && typeof configOrPath !== "string" ? configOrPath : {};
|
|
834
845
|
const mode = inlineConfig.mode ?? "global";
|
|
835
846
|
const plugins = [
|
|
847
|
+
ConfigHMRPlugin(ctx),
|
|
836
848
|
...initTransformerPlugins(ctx),
|
|
837
|
-
...createDevtoolsPlugin(ctx)
|
|
838
|
-
ConfigHMRPlugin(ctx)
|
|
849
|
+
...createDevtoolsPlugin(ctx)
|
|
839
850
|
];
|
|
840
851
|
if (inlineConfig.inspector !== false)
|
|
841
852
|
plugins.push(UnocssInspector__default(ctx));
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import UnocssInspector from '@unocss/inspector';
|
|
2
2
|
import { createFilter } from '@rollup/pluginutils';
|
|
3
|
-
import {
|
|
3
|
+
import { loadConfig } from '@unocss/config';
|
|
4
4
|
import { createGenerator, BetterMap, toEscapedSelector } from '@unocss/core';
|
|
5
5
|
import { createHash } from 'crypto';
|
|
6
6
|
import MagicString from 'magic-string';
|
|
@@ -44,16 +44,16 @@ const CSS_PLACEHOLDER = "@unocss-placeholder";
|
|
|
44
44
|
|
|
45
45
|
function createContext(configOrPath, defaults = {}, extraConfigSources = [], resolveConfigResult = () => {
|
|
46
46
|
}) {
|
|
47
|
-
|
|
47
|
+
let root = process.cwd();
|
|
48
48
|
let rawConfig = {};
|
|
49
49
|
const uno = createGenerator(rawConfig, defaults);
|
|
50
50
|
let rollupFilter = createFilter(defaultInclude, defaultExclude);
|
|
51
51
|
const invalidations = [];
|
|
52
52
|
const modules = new BetterMap();
|
|
53
53
|
const tokens = /* @__PURE__ */ new Set();
|
|
54
|
-
|
|
54
|
+
let ready = reloadConfig();
|
|
55
55
|
async function reloadConfig() {
|
|
56
|
-
const result = await loadConfig();
|
|
56
|
+
const result = await loadConfig(root, configOrPath, extraConfigSources);
|
|
57
57
|
resolveConfigResult(result);
|
|
58
58
|
rawConfig = result.config;
|
|
59
59
|
uno.setConfig(rawConfig);
|
|
@@ -64,6 +64,13 @@ function createContext(configOrPath, defaults = {}, extraConfigSources = [], res
|
|
|
64
64
|
invalidate();
|
|
65
65
|
return result;
|
|
66
66
|
}
|
|
67
|
+
async function updateRoot(newRoot) {
|
|
68
|
+
if (newRoot !== root) {
|
|
69
|
+
root = newRoot;
|
|
70
|
+
ready = reloadConfig();
|
|
71
|
+
}
|
|
72
|
+
return await ready;
|
|
73
|
+
}
|
|
67
74
|
function invalidate() {
|
|
68
75
|
invalidations.forEach((cb) => cb());
|
|
69
76
|
}
|
|
@@ -83,7 +90,9 @@ function createContext(configOrPath, defaults = {}, extraConfigSources = [], res
|
|
|
83
90
|
return rawConfig;
|
|
84
91
|
}
|
|
85
92
|
return {
|
|
86
|
-
ready
|
|
93
|
+
get ready() {
|
|
94
|
+
return ready;
|
|
95
|
+
},
|
|
87
96
|
tokens,
|
|
88
97
|
modules,
|
|
89
98
|
invalidate,
|
|
@@ -94,7 +103,9 @@ function createContext(configOrPath, defaults = {}, extraConfigSources = [], res
|
|
|
94
103
|
reloadConfig,
|
|
95
104
|
uno,
|
|
96
105
|
extract,
|
|
97
|
-
getConfig
|
|
106
|
+
getConfig,
|
|
107
|
+
root,
|
|
108
|
+
updateRoot
|
|
98
109
|
};
|
|
99
110
|
}
|
|
100
111
|
|
|
@@ -611,8 +622,8 @@ function ConfigHMRPlugin(ctx) {
|
|
|
611
622
|
const { ready, uno } = ctx;
|
|
612
623
|
return {
|
|
613
624
|
name: "unocss:config",
|
|
614
|
-
async configResolved() {
|
|
615
|
-
await
|
|
625
|
+
async configResolved(config) {
|
|
626
|
+
await ctx.updateRoot(config.root);
|
|
616
627
|
},
|
|
617
628
|
async configureServer(server) {
|
|
618
629
|
uno.config.envMode = "dev";
|
|
@@ -823,9 +834,9 @@ function UnocssPlugin(configOrPath, defaults = {}) {
|
|
|
823
834
|
const inlineConfig = configOrPath && typeof configOrPath !== "string" ? configOrPath : {};
|
|
824
835
|
const mode = inlineConfig.mode ?? "global";
|
|
825
836
|
const plugins = [
|
|
837
|
+
ConfigHMRPlugin(ctx),
|
|
826
838
|
...initTransformerPlugins(ctx),
|
|
827
|
-
...createDevtoolsPlugin(ctx)
|
|
828
|
-
ConfigHMRPlugin(ctx)
|
|
839
|
+
...createDevtoolsPlugin(ctx)
|
|
829
840
|
];
|
|
830
841
|
if (inlineConfig.inspector !== false)
|
|
831
842
|
plugins.push(UnocssInspector(ctx));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unocss/vite",
|
|
3
|
-
"version": "0.31.
|
|
3
|
+
"version": "0.31.13",
|
|
4
4
|
"description": "The Vite plugin for UnoCSS",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"unocss",
|
|
@@ -43,11 +43,11 @@
|
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@rollup/pluginutils": "^4.2.1",
|
|
46
|
-
"@unocss/config": "0.31.
|
|
47
|
-
"@unocss/core": "0.31.
|
|
48
|
-
"@unocss/inspector": "0.31.
|
|
49
|
-
"@unocss/scope": "0.31.
|
|
50
|
-
"@unocss/transformer-directives": "0.31.
|
|
46
|
+
"@unocss/config": "0.31.13",
|
|
47
|
+
"@unocss/core": "0.31.13",
|
|
48
|
+
"@unocss/inspector": "0.31.13",
|
|
49
|
+
"@unocss/scope": "0.31.13",
|
|
50
|
+
"@unocss/transformer-directives": "0.31.13",
|
|
51
51
|
"magic-string": "^0.26.1"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|