@unocss/webpack 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 CHANGED
@@ -49,16 +49,17 @@ const CSS_PLACEHOLDER = "@unocss-placeholder";
49
49
 
50
50
  function createContext(configOrPath, defaults = {}, extraConfigSources = [], resolveConfigResult = () => {
51
51
  }) {
52
- const loadConfig = config.createConfigLoader(configOrPath, extraConfigSources);
52
+ let root = process.cwd();
53
+ const loadConfig = config.createConfigLoader(configOrPath || root, extraConfigSources);
53
54
  let rawConfig = {};
54
55
  const uno = core.createGenerator(rawConfig, defaults);
55
56
  let rollupFilter = pluginutils.createFilter(defaultInclude, defaultExclude);
56
57
  const invalidations = [];
57
58
  const modules = new core.BetterMap();
58
59
  const tokens = /* @__PURE__ */ new Set();
59
- const ready = reloadConfig();
60
+ let ready = reloadConfig();
60
61
  async function reloadConfig() {
61
- const result = await loadConfig();
62
+ const result = await loadConfig(configOrPath || root);
62
63
  resolveConfigResult(result);
63
64
  rawConfig = result.config;
64
65
  uno.setConfig(rawConfig);
@@ -69,6 +70,13 @@ function createContext(configOrPath, defaults = {}, extraConfigSources = [], res
69
70
  invalidate();
70
71
  return result;
71
72
  }
73
+ async function updateRoot(newRoot) {
74
+ if (newRoot !== root) {
75
+ root = newRoot;
76
+ ready = reloadConfig();
77
+ }
78
+ return await ready;
79
+ }
72
80
  function invalidate() {
73
81
  invalidations.forEach((cb) => cb());
74
82
  }
@@ -88,7 +96,9 @@ function createContext(configOrPath, defaults = {}, extraConfigSources = [], res
88
96
  return rawConfig;
89
97
  }
90
98
  return {
91
- ready,
99
+ get ready() {
100
+ return ready;
101
+ },
92
102
  tokens,
93
103
  modules,
94
104
  invalidate,
@@ -99,7 +109,9 @@ function createContext(configOrPath, defaults = {}, extraConfigSources = [], res
99
109
  reloadConfig,
100
110
  uno,
101
111
  extract,
102
- getConfig
112
+ getConfig,
113
+ root,
114
+ updateRoot
103
115
  };
104
116
  }
105
117
 
package/dist/index.mjs CHANGED
@@ -41,16 +41,17 @@ const CSS_PLACEHOLDER = "@unocss-placeholder";
41
41
 
42
42
  function createContext(configOrPath, defaults = {}, extraConfigSources = [], resolveConfigResult = () => {
43
43
  }) {
44
- const loadConfig = createConfigLoader(configOrPath, extraConfigSources);
44
+ let root = process.cwd();
45
+ const loadConfig = createConfigLoader(configOrPath || root, extraConfigSources);
45
46
  let rawConfig = {};
46
47
  const uno = createGenerator(rawConfig, defaults);
47
48
  let rollupFilter = createFilter(defaultInclude, defaultExclude);
48
49
  const invalidations = [];
49
50
  const modules = new BetterMap();
50
51
  const tokens = /* @__PURE__ */ new Set();
51
- const ready = reloadConfig();
52
+ let ready = reloadConfig();
52
53
  async function reloadConfig() {
53
- const result = await loadConfig();
54
+ const result = await loadConfig(configOrPath || root);
54
55
  resolveConfigResult(result);
55
56
  rawConfig = result.config;
56
57
  uno.setConfig(rawConfig);
@@ -61,6 +62,13 @@ function createContext(configOrPath, defaults = {}, extraConfigSources = [], res
61
62
  invalidate();
62
63
  return result;
63
64
  }
65
+ async function updateRoot(newRoot) {
66
+ if (newRoot !== root) {
67
+ root = newRoot;
68
+ ready = reloadConfig();
69
+ }
70
+ return await ready;
71
+ }
64
72
  function invalidate() {
65
73
  invalidations.forEach((cb) => cb());
66
74
  }
@@ -80,7 +88,9 @@ function createContext(configOrPath, defaults = {}, extraConfigSources = [], res
80
88
  return rawConfig;
81
89
  }
82
90
  return {
83
- ready,
91
+ get ready() {
92
+ return ready;
93
+ },
84
94
  tokens,
85
95
  modules,
86
96
  invalidate,
@@ -91,7 +101,9 @@ function createContext(configOrPath, defaults = {}, extraConfigSources = [], res
91
101
  reloadConfig,
92
102
  uno,
93
103
  extract,
94
- getConfig
104
+ getConfig,
105
+ root,
106
+ updateRoot
95
107
  };
96
108
  }
97
109
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unocss/webpack",
3
- "version": "0.31.9",
3
+ "version": "0.31.10",
4
4
  "description": "The Webpack plugin for UnoCSS",
5
5
  "keywords": [
6
6
  "unocss",
@@ -37,8 +37,8 @@
37
37
  },
38
38
  "dependencies": {
39
39
  "@rollup/pluginutils": "^4.2.1",
40
- "@unocss/config": "0.31.9",
41
- "@unocss/core": "0.31.9",
40
+ "@unocss/config": "0.31.10",
41
+ "@unocss/core": "0.31.10",
42
42
  "unplugin": "^0.6.2",
43
43
  "webpack-sources": "^3.2.3"
44
44
  },