@unocss/vite 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 +41 -18
- package/dist/index.mjs +41 -18
- package/package.json +7 -7
package/dist/index.cjs
CHANGED
|
@@ -25,8 +25,8 @@ const fg__default = /*#__PURE__*/_interopDefaultLegacy(fg);
|
|
|
25
25
|
const remapping__default = /*#__PURE__*/_interopDefaultLegacy(remapping);
|
|
26
26
|
const fs__default$1 = /*#__PURE__*/_interopDefaultLegacy(fs$1);
|
|
27
27
|
|
|
28
|
-
const
|
|
29
|
-
const
|
|
28
|
+
const defaultPipelineExclude = [core.cssIdRE];
|
|
29
|
+
const defaultPipelineInclude = [/\.(vue|svelte|[jt]sx|mdx?|astro|elm|php|phtml|html)($|\?)/];
|
|
30
30
|
|
|
31
31
|
const VIRTUAL_ENTRY_ALIAS = [
|
|
32
32
|
/^(?:virtual:)?uno(?::(.+))?\.css(\?.*)?$/
|
|
@@ -62,13 +62,31 @@ const INCLUDE_COMMENT = "@unocss-include";
|
|
|
62
62
|
const IGNORE_COMMENT = "@unocss-ignore";
|
|
63
63
|
const CSS_PLACEHOLDER = "@unocss-placeholder";
|
|
64
64
|
|
|
65
|
+
function deprecationCheck(config) {
|
|
66
|
+
let warned = false;
|
|
67
|
+
function warn(msg) {
|
|
68
|
+
warned = true;
|
|
69
|
+
console.warn(`[unocss] ${msg}`);
|
|
70
|
+
}
|
|
71
|
+
if (config.include)
|
|
72
|
+
warn("`include` option is deprecated, use `content.pipeline.include` instead.");
|
|
73
|
+
if (config.exclude)
|
|
74
|
+
warn("`exclude` option is deprecated, use `content.pipeline.exclude` instead.");
|
|
75
|
+
if (config.extraContent)
|
|
76
|
+
warn("`extraContent` option is deprecated, use `content` instead.");
|
|
77
|
+
if (config.content?.plain)
|
|
78
|
+
warn("`content.plain` option is renamed to `content.inline`.");
|
|
79
|
+
if (warned && typeof process !== "undefined" && process.env.CI)
|
|
80
|
+
throw new Error("deprecation warning");
|
|
81
|
+
}
|
|
82
|
+
|
|
65
83
|
function createContext(configOrPath, defaults = {}, extraConfigSources = [], resolveConfigResult = () => {
|
|
66
84
|
}) {
|
|
67
85
|
let root = process.cwd();
|
|
68
86
|
let rawConfig = {};
|
|
69
87
|
let configFileList = [];
|
|
70
88
|
const uno = core.createGenerator(rawConfig, defaults);
|
|
71
|
-
let rollupFilter = pluginutils.createFilter(
|
|
89
|
+
let rollupFilter = pluginutils.createFilter(defaultPipelineInclude, defaultPipelineExclude);
|
|
72
90
|
const invalidations = [];
|
|
73
91
|
const reloadListeners = [];
|
|
74
92
|
const modules = new core.BetterMap();
|
|
@@ -79,13 +97,14 @@ function createContext(configOrPath, defaults = {}, extraConfigSources = [], res
|
|
|
79
97
|
async function reloadConfig() {
|
|
80
98
|
const result = await config.loadConfig(root, configOrPath, extraConfigSources, defaults);
|
|
81
99
|
resolveConfigResult(result);
|
|
100
|
+
deprecationCheck(result.config);
|
|
82
101
|
rawConfig = result.config;
|
|
83
102
|
configFileList = result.sources;
|
|
84
103
|
uno.setConfig(rawConfig);
|
|
85
104
|
uno.config.envMode = "dev";
|
|
86
|
-
rollupFilter = pluginutils.createFilter(
|
|
87
|
-
rawConfig.include ||
|
|
88
|
-
rawConfig.exclude ||
|
|
105
|
+
rollupFilter = rawConfig.content?.pipeline === false ? () => false : pluginutils.createFilter(
|
|
106
|
+
rawConfig.content?.pipeline?.include || rawConfig.include || defaultPipelineInclude,
|
|
107
|
+
rawConfig.content?.pipeline?.exclude || rawConfig.exclude || defaultPipelineExclude
|
|
89
108
|
);
|
|
90
109
|
tokens.clear();
|
|
91
110
|
await Promise.all(modules.map((code, id) => uno.applyExtractors(code, id, tokens)));
|
|
@@ -269,18 +288,22 @@ async function applyTransformers(ctx, original, id, enforce = "default") {
|
|
|
269
288
|
}
|
|
270
289
|
}
|
|
271
290
|
|
|
272
|
-
async function
|
|
273
|
-
const {
|
|
291
|
+
async function setupContentExtractor(ctx, shouldWatch = false) {
|
|
292
|
+
const { content } = await ctx.getConfig();
|
|
274
293
|
const { extract, tasks, root, filter } = ctx;
|
|
275
|
-
if (
|
|
294
|
+
if (content?.inline) {
|
|
276
295
|
await Promise.all(
|
|
277
|
-
|
|
278
|
-
|
|
296
|
+
content.inline.map(async (c, idx) => {
|
|
297
|
+
if (typeof c === "function")
|
|
298
|
+
c = await c();
|
|
299
|
+
if (typeof c === "string")
|
|
300
|
+
c = { code: c };
|
|
301
|
+
return extract(c.code, c.id ?? `__plain_content_${idx}__`);
|
|
279
302
|
})
|
|
280
303
|
);
|
|
281
304
|
}
|
|
282
|
-
if (
|
|
283
|
-
const files = await fg__default(
|
|
305
|
+
if (content?.filesystem) {
|
|
306
|
+
const files = await fg__default(content.filesystem, { cwd: root });
|
|
284
307
|
async function extractFile(file) {
|
|
285
308
|
const code = await fs__default.readFile(file, "utf-8");
|
|
286
309
|
if (!filter(code, file))
|
|
@@ -451,7 +474,7 @@ function GlobalModeBuildPlugin(ctx) {
|
|
|
451
474
|
viteConfig = config;
|
|
452
475
|
},
|
|
453
476
|
buildStart() {
|
|
454
|
-
tasks.push(
|
|
477
|
+
tasks.push(setupContentExtractor(ctx, viteConfig.command === "serve"));
|
|
455
478
|
}
|
|
456
479
|
},
|
|
457
480
|
{
|
|
@@ -818,7 +841,7 @@ ${css}`;
|
|
|
818
841
|
}
|
|
819
842
|
|
|
820
843
|
function VueScopedPlugin({ uno, ready }) {
|
|
821
|
-
let filter = pluginutils.createFilter([/\.vue$/],
|
|
844
|
+
let filter = pluginutils.createFilter([/\.vue$/], defaultPipelineExclude);
|
|
822
845
|
async function transformSFC(code) {
|
|
823
846
|
const { css } = await uno.generate(code);
|
|
824
847
|
if (!css)
|
|
@@ -831,9 +854,9 @@ function VueScopedPlugin({ uno, ready }) {
|
|
|
831
854
|
enforce: "pre",
|
|
832
855
|
async configResolved() {
|
|
833
856
|
const { config } = await ready;
|
|
834
|
-
filter = pluginutils.createFilter(
|
|
835
|
-
config.include
|
|
836
|
-
config.exclude
|
|
857
|
+
filter = config.content?.pipeline === false ? () => false : pluginutils.createFilter(
|
|
858
|
+
config.content?.pipeline?.include ?? config.include ?? [/\.vue$/],
|
|
859
|
+
config.content?.pipeline?.exclude ?? config.exclude ?? defaultPipelineExclude
|
|
837
860
|
);
|
|
838
861
|
},
|
|
839
862
|
transform(code, id) {
|
package/dist/index.mjs
CHANGED
|
@@ -12,8 +12,8 @@ import { Buffer } from 'node:buffer';
|
|
|
12
12
|
import fs$1 from 'node:fs';
|
|
13
13
|
import { fileURLToPath } from 'node:url';
|
|
14
14
|
|
|
15
|
-
const
|
|
16
|
-
const
|
|
15
|
+
const defaultPipelineExclude = [cssIdRE];
|
|
16
|
+
const defaultPipelineInclude = [/\.(vue|svelte|[jt]sx|mdx?|astro|elm|php|phtml|html)($|\?)/];
|
|
17
17
|
|
|
18
18
|
const VIRTUAL_ENTRY_ALIAS = [
|
|
19
19
|
/^(?:virtual:)?uno(?::(.+))?\.css(\?.*)?$/
|
|
@@ -49,13 +49,31 @@ const INCLUDE_COMMENT = "@unocss-include";
|
|
|
49
49
|
const IGNORE_COMMENT = "@unocss-ignore";
|
|
50
50
|
const CSS_PLACEHOLDER = "@unocss-placeholder";
|
|
51
51
|
|
|
52
|
+
function deprecationCheck(config) {
|
|
53
|
+
let warned = false;
|
|
54
|
+
function warn(msg) {
|
|
55
|
+
warned = true;
|
|
56
|
+
console.warn(`[unocss] ${msg}`);
|
|
57
|
+
}
|
|
58
|
+
if (config.include)
|
|
59
|
+
warn("`include` option is deprecated, use `content.pipeline.include` instead.");
|
|
60
|
+
if (config.exclude)
|
|
61
|
+
warn("`exclude` option is deprecated, use `content.pipeline.exclude` instead.");
|
|
62
|
+
if (config.extraContent)
|
|
63
|
+
warn("`extraContent` option is deprecated, use `content` instead.");
|
|
64
|
+
if (config.content?.plain)
|
|
65
|
+
warn("`content.plain` option is renamed to `content.inline`.");
|
|
66
|
+
if (warned && typeof process !== "undefined" && process.env.CI)
|
|
67
|
+
throw new Error("deprecation warning");
|
|
68
|
+
}
|
|
69
|
+
|
|
52
70
|
function createContext(configOrPath, defaults = {}, extraConfigSources = [], resolveConfigResult = () => {
|
|
53
71
|
}) {
|
|
54
72
|
let root = process.cwd();
|
|
55
73
|
let rawConfig = {};
|
|
56
74
|
let configFileList = [];
|
|
57
75
|
const uno = createGenerator(rawConfig, defaults);
|
|
58
|
-
let rollupFilter = createFilter(
|
|
76
|
+
let rollupFilter = createFilter(defaultPipelineInclude, defaultPipelineExclude);
|
|
59
77
|
const invalidations = [];
|
|
60
78
|
const reloadListeners = [];
|
|
61
79
|
const modules = new BetterMap();
|
|
@@ -66,13 +84,14 @@ function createContext(configOrPath, defaults = {}, extraConfigSources = [], res
|
|
|
66
84
|
async function reloadConfig() {
|
|
67
85
|
const result = await loadConfig(root, configOrPath, extraConfigSources, defaults);
|
|
68
86
|
resolveConfigResult(result);
|
|
87
|
+
deprecationCheck(result.config);
|
|
69
88
|
rawConfig = result.config;
|
|
70
89
|
configFileList = result.sources;
|
|
71
90
|
uno.setConfig(rawConfig);
|
|
72
91
|
uno.config.envMode = "dev";
|
|
73
|
-
rollupFilter = createFilter(
|
|
74
|
-
rawConfig.include ||
|
|
75
|
-
rawConfig.exclude ||
|
|
92
|
+
rollupFilter = rawConfig.content?.pipeline === false ? () => false : createFilter(
|
|
93
|
+
rawConfig.content?.pipeline?.include || rawConfig.include || defaultPipelineInclude,
|
|
94
|
+
rawConfig.content?.pipeline?.exclude || rawConfig.exclude || defaultPipelineExclude
|
|
76
95
|
);
|
|
77
96
|
tokens.clear();
|
|
78
97
|
await Promise.all(modules.map((code, id) => uno.applyExtractors(code, id, tokens)));
|
|
@@ -256,18 +275,22 @@ async function applyTransformers(ctx, original, id, enforce = "default") {
|
|
|
256
275
|
}
|
|
257
276
|
}
|
|
258
277
|
|
|
259
|
-
async function
|
|
260
|
-
const {
|
|
278
|
+
async function setupContentExtractor(ctx, shouldWatch = false) {
|
|
279
|
+
const { content } = await ctx.getConfig();
|
|
261
280
|
const { extract, tasks, root, filter } = ctx;
|
|
262
|
-
if (
|
|
281
|
+
if (content?.inline) {
|
|
263
282
|
await Promise.all(
|
|
264
|
-
|
|
265
|
-
|
|
283
|
+
content.inline.map(async (c, idx) => {
|
|
284
|
+
if (typeof c === "function")
|
|
285
|
+
c = await c();
|
|
286
|
+
if (typeof c === "string")
|
|
287
|
+
c = { code: c };
|
|
288
|
+
return extract(c.code, c.id ?? `__plain_content_${idx}__`);
|
|
266
289
|
})
|
|
267
290
|
);
|
|
268
291
|
}
|
|
269
|
-
if (
|
|
270
|
-
const files = await fg(
|
|
292
|
+
if (content?.filesystem) {
|
|
293
|
+
const files = await fg(content.filesystem, { cwd: root });
|
|
271
294
|
async function extractFile(file) {
|
|
272
295
|
const code = await fs.readFile(file, "utf-8");
|
|
273
296
|
if (!filter(code, file))
|
|
@@ -438,7 +461,7 @@ function GlobalModeBuildPlugin(ctx) {
|
|
|
438
461
|
viteConfig = config;
|
|
439
462
|
},
|
|
440
463
|
buildStart() {
|
|
441
|
-
tasks.push(
|
|
464
|
+
tasks.push(setupContentExtractor(ctx, viteConfig.command === "serve"));
|
|
442
465
|
}
|
|
443
466
|
},
|
|
444
467
|
{
|
|
@@ -805,7 +828,7 @@ ${css}`;
|
|
|
805
828
|
}
|
|
806
829
|
|
|
807
830
|
function VueScopedPlugin({ uno, ready }) {
|
|
808
|
-
let filter = createFilter([/\.vue$/],
|
|
831
|
+
let filter = createFilter([/\.vue$/], defaultPipelineExclude);
|
|
809
832
|
async function transformSFC(code) {
|
|
810
833
|
const { css } = await uno.generate(code);
|
|
811
834
|
if (!css)
|
|
@@ -818,9 +841,9 @@ function VueScopedPlugin({ uno, ready }) {
|
|
|
818
841
|
enforce: "pre",
|
|
819
842
|
async configResolved() {
|
|
820
843
|
const { config } = await ready;
|
|
821
|
-
filter = createFilter(
|
|
822
|
-
config.include
|
|
823
|
-
config.exclude
|
|
844
|
+
filter = config.content?.pipeline === false ? () => false : createFilter(
|
|
845
|
+
config.content?.pipeline?.include ?? config.include ?? [/\.vue$/],
|
|
846
|
+
config.content?.pipeline?.exclude ?? config.exclude ?? defaultPipelineExclude
|
|
824
847
|
);
|
|
825
848
|
},
|
|
826
849
|
transform(code, id) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unocss/vite",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.53.0",
|
|
4
4
|
"description": "The Vite plugin for UnoCSS",
|
|
5
5
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -47,15 +47,15 @@
|
|
|
47
47
|
"chokidar": "^3.5.3",
|
|
48
48
|
"fast-glob": "^3.2.12",
|
|
49
49
|
"magic-string": "^0.30.0",
|
|
50
|
-
"@unocss/config": "0.
|
|
51
|
-
"@unocss/core": "0.
|
|
52
|
-
"@unocss/inspector": "0.
|
|
53
|
-
"@unocss/scope": "0.
|
|
54
|
-
"@unocss/transformer-directives": "0.
|
|
50
|
+
"@unocss/config": "0.53.0",
|
|
51
|
+
"@unocss/core": "0.53.0",
|
|
52
|
+
"@unocss/inspector": "0.53.0",
|
|
53
|
+
"@unocss/scope": "0.53.0",
|
|
54
|
+
"@unocss/transformer-directives": "0.53.0"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"vite": "^4.3.9",
|
|
58
|
-
"@unocss/shared-integration": "0.
|
|
58
|
+
"@unocss/shared-integration": "0.53.0"
|
|
59
59
|
},
|
|
60
60
|
"scripts": {
|
|
61
61
|
"build": "unbuild",
|