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