@unocss/webpack 0.57.1 → 0.57.3

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
@@ -149,7 +149,9 @@ function createContext(configOrPath, defaults = {}, extraConfigSources = [], res
149
149
  uno,
150
150
  extract,
151
151
  getConfig,
152
- root,
152
+ get root() {
153
+ return root;
154
+ },
153
155
  updateRoot,
154
156
  getConfigFileList: () => configFileList
155
157
  };
@@ -235,6 +237,7 @@ async function setupContentExtractor(ctx, shouldWatch = false) {
235
237
  if (content?.filesystem) {
236
238
  const files = await fg__default(content.filesystem, { cwd: root });
237
239
  async function extractFile(file) {
240
+ file = node_path.isAbsolute(file) ? file : node_path.resolve(root, file);
238
241
  const code = await fs__default.readFile(file, "utf-8");
239
242
  if (!filter(code, file))
240
243
  return;
@@ -324,7 +327,7 @@ function WebpackPlugin(configOrPath, defaults) {
324
327
  '[unocss] webpack integration only supports "pre" enforce transformers currently.the following transformers will be ignored\n' + nonPreTransformers.map((i) => ` - ${i.name}`).join("\n")
325
328
  );
326
329
  }
327
- tasks.push(setupContentExtractor(ctx));
330
+ tasks.push(setupContentExtractor(ctx, typeof configOrPath === "object" && configOrPath?.watch));
328
331
  const entries = /* @__PURE__ */ new Set();
329
332
  const hashes = /* @__PURE__ */ new Map();
330
333
  const plugin = {
package/dist/index.d.cts CHANGED
@@ -2,6 +2,12 @@ import * as webpack from 'webpack';
2
2
  import { UserConfig, UserConfigDefaults } from '@unocss/core';
3
3
 
4
4
  interface WebpackPluginOptions<Theme extends object = object> extends UserConfig<Theme> {
5
+ /**
6
+ * Manually enable watch mode
7
+ *
8
+ * @default false
9
+ */
10
+ watch?: boolean;
5
11
  }
6
12
  declare function defineConfig<Theme extends object>(config: WebpackPluginOptions<Theme>): WebpackPluginOptions<Theme>;
7
13
  declare function WebpackPlugin<Theme extends object>(configOrPath?: WebpackPluginOptions<Theme> | string, defaults?: UserConfigDefaults): webpack.WebpackPluginInstance;
package/dist/index.d.mts CHANGED
@@ -2,6 +2,12 @@ import * as webpack from 'webpack';
2
2
  import { UserConfig, UserConfigDefaults } from '@unocss/core';
3
3
 
4
4
  interface WebpackPluginOptions<Theme extends object = object> extends UserConfig<Theme> {
5
+ /**
6
+ * Manually enable watch mode
7
+ *
8
+ * @default false
9
+ */
10
+ watch?: boolean;
5
11
  }
6
12
  declare function defineConfig<Theme extends object>(config: WebpackPluginOptions<Theme>): WebpackPluginOptions<Theme>;
7
13
  declare function WebpackPlugin<Theme extends object>(configOrPath?: WebpackPluginOptions<Theme> | string, defaults?: UserConfigDefaults): webpack.WebpackPluginInstance;
package/dist/index.d.ts CHANGED
@@ -2,6 +2,12 @@ import * as webpack from 'webpack';
2
2
  import { UserConfig, UserConfigDefaults } from '@unocss/core';
3
3
 
4
4
  interface WebpackPluginOptions<Theme extends object = object> extends UserConfig<Theme> {
5
+ /**
6
+ * Manually enable watch mode
7
+ *
8
+ * @default false
9
+ */
10
+ watch?: boolean;
5
11
  }
6
12
  declare function defineConfig<Theme extends object>(config: WebpackPluginOptions<Theme>): WebpackPluginOptions<Theme>;
7
13
  declare function WebpackPlugin<Theme extends object>(configOrPath?: WebpackPluginOptions<Theme> | string, defaults?: UserConfigDefaults): webpack.WebpackPluginInstance;
package/dist/index.mjs CHANGED
@@ -5,7 +5,7 @@ import { createFilter } from '@rollup/pluginutils';
5
5
  import { loadConfig } from '@unocss/config';
6
6
  import { cssIdRE, createGenerator, BetterMap } from '@unocss/core';
7
7
  import fs from 'node:fs/promises';
8
- import { resolve } from 'node:path';
8
+ import { resolve, isAbsolute } from 'node:path';
9
9
  import fg from 'fast-glob';
10
10
  import MagicString from 'magic-string';
11
11
  import remapping from '@ampproject/remapping';
@@ -136,7 +136,9 @@ function createContext(configOrPath, defaults = {}, extraConfigSources = [], res
136
136
  uno,
137
137
  extract,
138
138
  getConfig,
139
- root,
139
+ get root() {
140
+ return root;
141
+ },
140
142
  updateRoot,
141
143
  getConfigFileList: () => configFileList
142
144
  };
@@ -222,6 +224,7 @@ async function setupContentExtractor(ctx, shouldWatch = false) {
222
224
  if (content?.filesystem) {
223
225
  const files = await fg(content.filesystem, { cwd: root });
224
226
  async function extractFile(file) {
227
+ file = isAbsolute(file) ? file : resolve(root, file);
225
228
  const code = await fs.readFile(file, "utf-8");
226
229
  if (!filter(code, file))
227
230
  return;
@@ -311,7 +314,7 @@ function WebpackPlugin(configOrPath, defaults) {
311
314
  '[unocss] webpack integration only supports "pre" enforce transformers currently.the following transformers will be ignored\n' + nonPreTransformers.map((i) => ` - ${i.name}`).join("\n")
312
315
  );
313
316
  }
314
- tasks.push(setupContentExtractor(ctx));
317
+ tasks.push(setupContentExtractor(ctx, typeof configOrPath === "object" && configOrPath?.watch));
315
318
  const entries = /* @__PURE__ */ new Set();
316
319
  const hashes = /* @__PURE__ */ new Map();
317
320
  const plugin = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unocss/webpack",
3
- "version": "0.57.1",
3
+ "version": "0.57.3",
4
4
  "description": "The Webpack plugin for UnoCSS",
5
5
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
6
6
  "license": "MIT",
@@ -39,16 +39,16 @@
39
39
  "@ampproject/remapping": "^2.2.1",
40
40
  "@rollup/pluginutils": "^5.0.5",
41
41
  "chokidar": "^3.5.3",
42
- "fast-glob": "^3.3.1",
42
+ "fast-glob": "^3.3.2",
43
43
  "magic-string": "^0.30.5",
44
44
  "unplugin": "^1.5.0",
45
45
  "webpack-sources": "^3.2.3",
46
- "@unocss/config": "0.57.1",
47
- "@unocss/core": "0.57.1"
46
+ "@unocss/config": "0.57.3",
47
+ "@unocss/core": "0.57.3"
48
48
  },
49
49
  "devDependencies": {
50
- "@types/webpack": "^5.28.4",
51
- "@types/webpack-sources": "^3.2.2",
50
+ "@types/webpack": "^5.28.5",
51
+ "@types/webpack-sources": "^3.2.3",
52
52
  "webpack": "^5.89.0"
53
53
  },
54
54
  "scripts": {