@unocss/webpack 0.52.7 → 0.53.0
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 +37 -14
- package/dist/index.mjs +37 -14
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -26,8 +26,26 @@ const INCLUDE_COMMENT = "@unocss-include";
|
|
|
26
26
|
const IGNORE_COMMENT = "@unocss-ignore";
|
|
27
27
|
const CSS_PLACEHOLDER = "@unocss-placeholder";
|
|
28
28
|
|
|
29
|
-
const
|
|
30
|
-
const
|
|
29
|
+
const defaultPipelineExclude = [core.cssIdRE];
|
|
30
|
+
const defaultPipelineInclude = [/\.(vue|svelte|[jt]sx|mdx?|astro|elm|php|phtml|html)($|\?)/];
|
|
31
|
+
|
|
32
|
+
function deprecationCheck(config) {
|
|
33
|
+
let warned = false;
|
|
34
|
+
function warn(msg) {
|
|
35
|
+
warned = true;
|
|
36
|
+
console.warn(`[unocss] ${msg}`);
|
|
37
|
+
}
|
|
38
|
+
if (config.include)
|
|
39
|
+
warn("`include` option is deprecated, use `content.pipeline.include` instead.");
|
|
40
|
+
if (config.exclude)
|
|
41
|
+
warn("`exclude` option is deprecated, use `content.pipeline.exclude` instead.");
|
|
42
|
+
if (config.extraContent)
|
|
43
|
+
warn("`extraContent` option is deprecated, use `content` instead.");
|
|
44
|
+
if (config.content?.plain)
|
|
45
|
+
warn("`content.plain` option is renamed to `content.inline`.");
|
|
46
|
+
if (warned && typeof process !== "undefined" && process.env.CI)
|
|
47
|
+
throw new Error("deprecation warning");
|
|
48
|
+
}
|
|
31
49
|
|
|
32
50
|
function createContext(configOrPath, defaults = {}, extraConfigSources = [], resolveConfigResult = () => {
|
|
33
51
|
}) {
|
|
@@ -35,7 +53,7 @@ function createContext(configOrPath, defaults = {}, extraConfigSources = [], res
|
|
|
35
53
|
let rawConfig = {};
|
|
36
54
|
let configFileList = [];
|
|
37
55
|
const uno = core.createGenerator(rawConfig, defaults);
|
|
38
|
-
let rollupFilter = pluginutils.createFilter(
|
|
56
|
+
let rollupFilter = pluginutils.createFilter(defaultPipelineInclude, defaultPipelineExclude);
|
|
39
57
|
const invalidations = [];
|
|
40
58
|
const reloadListeners = [];
|
|
41
59
|
const modules = new core.BetterMap();
|
|
@@ -46,13 +64,14 @@ function createContext(configOrPath, defaults = {}, extraConfigSources = [], res
|
|
|
46
64
|
async function reloadConfig() {
|
|
47
65
|
const result = await config.loadConfig(root, configOrPath, extraConfigSources, defaults);
|
|
48
66
|
resolveConfigResult(result);
|
|
67
|
+
deprecationCheck(result.config);
|
|
49
68
|
rawConfig = result.config;
|
|
50
69
|
configFileList = result.sources;
|
|
51
70
|
uno.setConfig(rawConfig);
|
|
52
71
|
uno.config.envMode = "dev";
|
|
53
|
-
rollupFilter = pluginutils.createFilter(
|
|
54
|
-
rawConfig.include ||
|
|
55
|
-
rawConfig.exclude ||
|
|
72
|
+
rollupFilter = rawConfig.content?.pipeline === false ? () => false : pluginutils.createFilter(
|
|
73
|
+
rawConfig.content?.pipeline?.include || rawConfig.include || defaultPipelineInclude,
|
|
74
|
+
rawConfig.content?.pipeline?.exclude || rawConfig.exclude || defaultPipelineExclude
|
|
56
75
|
);
|
|
57
76
|
tokens.clear();
|
|
58
77
|
await Promise.all(modules.map((code, id) => uno.applyExtractors(code, id, tokens)));
|
|
@@ -163,18 +182,22 @@ async function applyTransformers(ctx, original, id, enforce = "default") {
|
|
|
163
182
|
}
|
|
164
183
|
}
|
|
165
184
|
|
|
166
|
-
async function
|
|
167
|
-
const {
|
|
185
|
+
async function setupContentExtractor(ctx, shouldWatch = false) {
|
|
186
|
+
const { content } = await ctx.getConfig();
|
|
168
187
|
const { extract, tasks, root, filter } = ctx;
|
|
169
|
-
if (
|
|
188
|
+
if (content?.inline) {
|
|
170
189
|
await Promise.all(
|
|
171
|
-
|
|
172
|
-
|
|
190
|
+
content.inline.map(async (c, idx) => {
|
|
191
|
+
if (typeof c === "function")
|
|
192
|
+
c = await c();
|
|
193
|
+
if (typeof c === "string")
|
|
194
|
+
c = { code: c };
|
|
195
|
+
return extract(c.code, c.id ?? `__plain_content_${idx}__`);
|
|
173
196
|
})
|
|
174
197
|
);
|
|
175
198
|
}
|
|
176
|
-
if (
|
|
177
|
-
const files = await fg__default(
|
|
199
|
+
if (content?.filesystem) {
|
|
200
|
+
const files = await fg__default(content.filesystem, { cwd: root });
|
|
178
201
|
async function extractFile(file) {
|
|
179
202
|
const code = await fs__default.readFile(file, "utf-8");
|
|
180
203
|
if (!filter(code, file))
|
|
@@ -265,7 +288,7 @@ function WebpackPlugin(configOrPath, defaults) {
|
|
|
265
288
|
'[unocss] webpack integration only supports "pre" enforce transformers currently.the following transformers will be ignored\n' + nonPreTransformers.map((i) => ` - ${i.name}`).join("\n")
|
|
266
289
|
);
|
|
267
290
|
}
|
|
268
|
-
tasks.push(
|
|
291
|
+
tasks.push(setupContentExtractor(ctx));
|
|
269
292
|
const entries = /* @__PURE__ */ new Set();
|
|
270
293
|
const hashes = /* @__PURE__ */ new Map();
|
|
271
294
|
const plugin = {
|
package/dist/index.mjs
CHANGED
|
@@ -14,8 +14,26 @@ const INCLUDE_COMMENT = "@unocss-include";
|
|
|
14
14
|
const IGNORE_COMMENT = "@unocss-ignore";
|
|
15
15
|
const CSS_PLACEHOLDER = "@unocss-placeholder";
|
|
16
16
|
|
|
17
|
-
const
|
|
18
|
-
const
|
|
17
|
+
const defaultPipelineExclude = [cssIdRE];
|
|
18
|
+
const defaultPipelineInclude = [/\.(vue|svelte|[jt]sx|mdx?|astro|elm|php|phtml|html)($|\?)/];
|
|
19
|
+
|
|
20
|
+
function deprecationCheck(config) {
|
|
21
|
+
let warned = false;
|
|
22
|
+
function warn(msg) {
|
|
23
|
+
warned = true;
|
|
24
|
+
console.warn(`[unocss] ${msg}`);
|
|
25
|
+
}
|
|
26
|
+
if (config.include)
|
|
27
|
+
warn("`include` option is deprecated, use `content.pipeline.include` instead.");
|
|
28
|
+
if (config.exclude)
|
|
29
|
+
warn("`exclude` option is deprecated, use `content.pipeline.exclude` instead.");
|
|
30
|
+
if (config.extraContent)
|
|
31
|
+
warn("`extraContent` option is deprecated, use `content` instead.");
|
|
32
|
+
if (config.content?.plain)
|
|
33
|
+
warn("`content.plain` option is renamed to `content.inline`.");
|
|
34
|
+
if (warned && typeof process !== "undefined" && process.env.CI)
|
|
35
|
+
throw new Error("deprecation warning");
|
|
36
|
+
}
|
|
19
37
|
|
|
20
38
|
function createContext(configOrPath, defaults = {}, extraConfigSources = [], resolveConfigResult = () => {
|
|
21
39
|
}) {
|
|
@@ -23,7 +41,7 @@ function createContext(configOrPath, defaults = {}, extraConfigSources = [], res
|
|
|
23
41
|
let rawConfig = {};
|
|
24
42
|
let configFileList = [];
|
|
25
43
|
const uno = createGenerator(rawConfig, defaults);
|
|
26
|
-
let rollupFilter = createFilter(
|
|
44
|
+
let rollupFilter = createFilter(defaultPipelineInclude, defaultPipelineExclude);
|
|
27
45
|
const invalidations = [];
|
|
28
46
|
const reloadListeners = [];
|
|
29
47
|
const modules = new BetterMap();
|
|
@@ -34,13 +52,14 @@ function createContext(configOrPath, defaults = {}, extraConfigSources = [], res
|
|
|
34
52
|
async function reloadConfig() {
|
|
35
53
|
const result = await loadConfig(root, configOrPath, extraConfigSources, defaults);
|
|
36
54
|
resolveConfigResult(result);
|
|
55
|
+
deprecationCheck(result.config);
|
|
37
56
|
rawConfig = result.config;
|
|
38
57
|
configFileList = result.sources;
|
|
39
58
|
uno.setConfig(rawConfig);
|
|
40
59
|
uno.config.envMode = "dev";
|
|
41
|
-
rollupFilter = createFilter(
|
|
42
|
-
rawConfig.include ||
|
|
43
|
-
rawConfig.exclude ||
|
|
60
|
+
rollupFilter = rawConfig.content?.pipeline === false ? () => false : createFilter(
|
|
61
|
+
rawConfig.content?.pipeline?.include || rawConfig.include || defaultPipelineInclude,
|
|
62
|
+
rawConfig.content?.pipeline?.exclude || rawConfig.exclude || defaultPipelineExclude
|
|
44
63
|
);
|
|
45
64
|
tokens.clear();
|
|
46
65
|
await Promise.all(modules.map((code, id) => uno.applyExtractors(code, id, tokens)));
|
|
@@ -151,18 +170,22 @@ async function applyTransformers(ctx, original, id, enforce = "default") {
|
|
|
151
170
|
}
|
|
152
171
|
}
|
|
153
172
|
|
|
154
|
-
async function
|
|
155
|
-
const {
|
|
173
|
+
async function setupContentExtractor(ctx, shouldWatch = false) {
|
|
174
|
+
const { content } = await ctx.getConfig();
|
|
156
175
|
const { extract, tasks, root, filter } = ctx;
|
|
157
|
-
if (
|
|
176
|
+
if (content?.inline) {
|
|
158
177
|
await Promise.all(
|
|
159
|
-
|
|
160
|
-
|
|
178
|
+
content.inline.map(async (c, idx) => {
|
|
179
|
+
if (typeof c === "function")
|
|
180
|
+
c = await c();
|
|
181
|
+
if (typeof c === "string")
|
|
182
|
+
c = { code: c };
|
|
183
|
+
return extract(c.code, c.id ?? `__plain_content_${idx}__`);
|
|
161
184
|
})
|
|
162
185
|
);
|
|
163
186
|
}
|
|
164
|
-
if (
|
|
165
|
-
const files = await fg(
|
|
187
|
+
if (content?.filesystem) {
|
|
188
|
+
const files = await fg(content.filesystem, { cwd: root });
|
|
166
189
|
async function extractFile(file) {
|
|
167
190
|
const code = await fs.readFile(file, "utf-8");
|
|
168
191
|
if (!filter(code, file))
|
|
@@ -253,7 +276,7 @@ function WebpackPlugin(configOrPath, defaults) {
|
|
|
253
276
|
'[unocss] webpack integration only supports "pre" enforce transformers currently.the following transformers will be ignored\n' + nonPreTransformers.map((i) => ` - ${i.name}`).join("\n")
|
|
254
277
|
);
|
|
255
278
|
}
|
|
256
|
-
tasks.push(
|
|
279
|
+
tasks.push(setupContentExtractor(ctx));
|
|
257
280
|
const entries = /* @__PURE__ */ new Set();
|
|
258
281
|
const hashes = /* @__PURE__ */ new Map();
|
|
259
282
|
const plugin = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unocss/webpack",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.53.0",
|
|
4
4
|
"description": "The Webpack plugin for UnoCSS",
|
|
5
5
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -43,13 +43,13 @@
|
|
|
43
43
|
"magic-string": "^0.30.0",
|
|
44
44
|
"unplugin": "^1.3.1",
|
|
45
45
|
"webpack-sources": "^3.2.3",
|
|
46
|
-
"@unocss/config": "0.
|
|
47
|
-
"@unocss/core": "0.
|
|
46
|
+
"@unocss/config": "0.53.0",
|
|
47
|
+
"@unocss/core": "0.53.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@types/webpack": "^5.28.1",
|
|
51
51
|
"@types/webpack-sources": "^3.2.0",
|
|
52
|
-
"webpack": "^5.
|
|
52
|
+
"webpack": "^5.85.0"
|
|
53
53
|
},
|
|
54
54
|
"scripts": {
|
|
55
55
|
"build": "unbuild",
|