@unocss/vite 0.55.0 → 0.55.2
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/client.d.cts +2 -0
- package/dist/client.d.mts +2 -0
- package/dist/client.d.ts +1 -0
- package/dist/index.cjs +21 -17
- package/dist/index.d.cts +69 -0
- package/dist/index.d.mts +69 -0
- package/dist/index.mjs +11 -7
- package/package.json +8 -8
package/dist/client.d.ts
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -3,29 +3,29 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const UnocssInspector = require('@unocss/inspector');
|
|
6
|
-
const core = require('@unocss/core');
|
|
7
|
-
const process$1 = require('node:process');
|
|
8
|
-
const pluginutils = require('@rollup/pluginutils');
|
|
9
|
-
const config = require('@unocss/config');
|
|
10
|
-
const node_crypto = require('node:crypto');
|
|
11
|
-
const MagicString = require('magic-string');
|
|
12
6
|
const node_path = require('node:path');
|
|
13
7
|
const fs = require('node:fs/promises');
|
|
14
8
|
const fg = require('fast-glob');
|
|
9
|
+
const MagicString = require('magic-string');
|
|
15
10
|
const remapping = require('@ampproject/remapping');
|
|
11
|
+
const node_crypto = require('node:crypto');
|
|
12
|
+
const core = require('@unocss/core');
|
|
13
|
+
const process$1 = require('node:process');
|
|
16
14
|
const node_buffer = require('node:buffer');
|
|
15
|
+
const pluginutils = require('@rollup/pluginutils');
|
|
17
16
|
const fs$1 = require('node:fs');
|
|
18
17
|
const node_url = require('node:url');
|
|
18
|
+
const config = require('@unocss/config');
|
|
19
19
|
|
|
20
|
-
function
|
|
20
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
21
21
|
|
|
22
|
-
const UnocssInspector__default = /*#__PURE__*/
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
const fs__default$1 = /*#__PURE__*/
|
|
22
|
+
const UnocssInspector__default = /*#__PURE__*/_interopDefaultCompat(UnocssInspector);
|
|
23
|
+
const fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
|
|
24
|
+
const fg__default = /*#__PURE__*/_interopDefaultCompat(fg);
|
|
25
|
+
const MagicString__default = /*#__PURE__*/_interopDefaultCompat(MagicString);
|
|
26
|
+
const remapping__default = /*#__PURE__*/_interopDefaultCompat(remapping);
|
|
27
|
+
const process__default = /*#__PURE__*/_interopDefaultCompat(process$1);
|
|
28
|
+
const fs__default$1 = /*#__PURE__*/_interopDefaultCompat(fs$1);
|
|
29
29
|
|
|
30
30
|
const defaultPipelineExclude = [core.cssIdRE];
|
|
31
31
|
const defaultPipelineInclude = [/\.(vue|svelte|[jt]sx|mdx?|astro|elm|php|phtml|html)($|\?)/];
|
|
@@ -473,6 +473,8 @@ function GlobalModeBuildPlugin(ctx) {
|
|
|
473
473
|
distDirs.forEach((dir) => cssPlugins.set(dir, cssPlugin));
|
|
474
474
|
await ready;
|
|
475
475
|
},
|
|
476
|
+
// we inject a hash to chunk before the dist hash calculation to make sure
|
|
477
|
+
// the hash is different when unocss changes
|
|
476
478
|
async renderChunk(_, chunk, options) {
|
|
477
479
|
if (isLegacyChunk(chunk, options))
|
|
478
480
|
return null;
|
|
@@ -537,6 +539,7 @@ function GlobalModeBuildPlugin(ctx) {
|
|
|
537
539
|
name: "unocss:global:build:bundle",
|
|
538
540
|
apply: "build",
|
|
539
541
|
enforce: "post",
|
|
542
|
+
// rewrite the css placeholders
|
|
540
543
|
async generateBundle(options, bundle) {
|
|
541
544
|
const checkJs = ["umd", "amd", "iife"].includes(options.format);
|
|
542
545
|
const files = Object.keys(bundle).filter((i) => i.endsWith(".css") || checkJs && i.endsWith(".js"));
|
|
@@ -731,6 +734,7 @@ function GlobalModeDevPlugin({ uno, tokens, tasks, flushTasks, affectedModules,
|
|
|
731
734
|
return null;
|
|
732
735
|
const { hash, css } = await generateCSS(layer);
|
|
733
736
|
return {
|
|
737
|
+
// add hash to the chunk of CSS that it will send back to client to check if there is new CSS generated
|
|
734
738
|
code: `__uno_hash_${hash}{--:'';}${css}`,
|
|
735
739
|
map: { mappings: "" }
|
|
736
740
|
};
|
|
@@ -1002,7 +1006,7 @@ function ShadowDomModuleModePlugin({ uno }) {
|
|
|
1002
1006
|
}
|
|
1003
1007
|
if (id.includes("?vue&type=style") || id.endsWith(".vue") && vueSFCStyleRE.test(code))
|
|
1004
1008
|
return code.replace(new RegExp(`(\\/\\*\\s*)?${CSS_PLACEHOLDER}(\\s*\\*\\/)?`), css || "");
|
|
1005
|
-
return code.replace(CSS_PLACEHOLDER, css?.replace(/\\/g, "\\\\") ?? "");
|
|
1009
|
+
return code.replace(CSS_PLACEHOLDER, css?.replace(/\\/g, "\\\\")?.replace(/`/g, "\\`") ?? "");
|
|
1006
1010
|
};
|
|
1007
1011
|
return {
|
|
1008
1012
|
name: "unocss:shadow-dom",
|
|
@@ -1063,7 +1067,7 @@ function createTransformerPlugins(ctx) {
|
|
|
1063
1067
|
}));
|
|
1064
1068
|
}
|
|
1065
1069
|
|
|
1066
|
-
const _dirname = typeof __dirname !== "undefined" ? __dirname : node_path.dirname(node_url.fileURLToPath((typeof document === 'undefined' ?
|
|
1070
|
+
const _dirname = typeof __dirname !== "undefined" ? __dirname : node_path.dirname(node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('index.cjs', document.baseURI).href))));
|
|
1067
1071
|
const DEVTOOLS_MODULE_ID = "virtual:unocss-devtools";
|
|
1068
1072
|
const MOCK_CLASSES_MODULE_ID = "virtual:unocss-mock-classes";
|
|
1069
1073
|
const MOCK_CLASSES_PATH = "/@unocss/mock-classes";
|
|
@@ -1240,5 +1244,5 @@ exports.GlobalModeDevPlugin = GlobalModeDevPlugin;
|
|
|
1240
1244
|
exports.GlobalModePlugin = GlobalModePlugin;
|
|
1241
1245
|
exports.PerModuleModePlugin = PerModuleModePlugin;
|
|
1242
1246
|
exports.VueScopedPlugin = VueScopedPlugin;
|
|
1243
|
-
exports
|
|
1247
|
+
exports.default = UnocssPlugin;
|
|
1244
1248
|
exports.defineConfig = defineConfig;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import * as vite from 'vite';
|
|
2
|
+
import { Plugin } from 'vite';
|
|
3
|
+
import { UserConfig, UnocssPluginContext, UserConfigDefaults } from '@unocss/core';
|
|
4
|
+
|
|
5
|
+
interface VitePluginConfig<Theme extends object = object> extends UserConfig<Theme> {
|
|
6
|
+
/**
|
|
7
|
+
* Enable UnoCSS inspector
|
|
8
|
+
*
|
|
9
|
+
* @default true
|
|
10
|
+
*/
|
|
11
|
+
inspector?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* CSS Generation mode
|
|
14
|
+
*
|
|
15
|
+
* - `global` - generate a single CSS sheet for entire App
|
|
16
|
+
* - `dist-chunk` - generate a CSS sheet for each code chunk on build, great for MPA
|
|
17
|
+
* - `per-module` - generate a CSS sheet for each module, can be scoped
|
|
18
|
+
* - `vue-scoped` - inject generated CSS to Vue SFC's `<style scoped>` for isolation
|
|
19
|
+
* - `shadow-dom` - inject generated CSS to `Shadow DOM` css style block for each web component
|
|
20
|
+
*
|
|
21
|
+
* @default 'global'
|
|
22
|
+
*/
|
|
23
|
+
mode?: 'global' | 'per-module' | 'vue-scoped' | 'dist-chunk' | 'shadow-dom';
|
|
24
|
+
/**
|
|
25
|
+
* Transform CSS for `@apply` directive
|
|
26
|
+
*
|
|
27
|
+
* @experimental
|
|
28
|
+
* @default false
|
|
29
|
+
*/
|
|
30
|
+
transformCSS?: boolean | 'pre' | 'post';
|
|
31
|
+
/**
|
|
32
|
+
* Make the generated css processed by postcss (https://vitejs.dev/guide/features.html#postcss)
|
|
33
|
+
*
|
|
34
|
+
* @default true
|
|
35
|
+
*/
|
|
36
|
+
postcss?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Use top level await in HMR code to avoid FOUC on dev time.
|
|
39
|
+
*
|
|
40
|
+
* You usually don't need to disable this, unless you are developing on
|
|
41
|
+
* a browser that does not support top level await.
|
|
42
|
+
*
|
|
43
|
+
* This will only affect on dev time.
|
|
44
|
+
*
|
|
45
|
+
* @default true
|
|
46
|
+
*/
|
|
47
|
+
hmrTopLevelAwait?: boolean;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
declare function ChunkModeBuildPlugin({ uno, filter }: UnocssPluginContext): Plugin;
|
|
51
|
+
|
|
52
|
+
declare function GlobalModeDevPlugin({ uno, tokens, tasks, flushTasks, affectedModules, onInvalidate, extract, filter, getConfig }: UnocssPluginContext): Plugin[];
|
|
53
|
+
|
|
54
|
+
declare function GlobalModeBuildPlugin(ctx: UnocssPluginContext<VitePluginConfig>): Plugin[];
|
|
55
|
+
|
|
56
|
+
declare function GlobalModePlugin(ctx: UnocssPluginContext): vite.Plugin[];
|
|
57
|
+
|
|
58
|
+
declare function PerModuleModePlugin({ uno, filter }: UnocssPluginContext): Plugin[];
|
|
59
|
+
|
|
60
|
+
declare function VueScopedPlugin({ uno, ready }: UnocssPluginContext): Plugin;
|
|
61
|
+
|
|
62
|
+
declare function defineConfig<Theme extends object>(config: VitePluginConfig<Theme>): VitePluginConfig<Theme>;
|
|
63
|
+
interface UnocssVitePluginAPI {
|
|
64
|
+
getContext(): UnocssPluginContext<VitePluginConfig>;
|
|
65
|
+
getMode(): VitePluginConfig['mode'];
|
|
66
|
+
}
|
|
67
|
+
declare function UnocssPlugin<Theme extends object>(configOrPath?: VitePluginConfig<Theme> | string, defaults?: UserConfigDefaults): Plugin[];
|
|
68
|
+
|
|
69
|
+
export { ChunkModeBuildPlugin, GlobalModeBuildPlugin, GlobalModeDevPlugin, GlobalModePlugin, PerModuleModePlugin, UnocssVitePluginAPI, VitePluginConfig, VueScopedPlugin, UnocssPlugin as default, defineConfig };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import * as vite from 'vite';
|
|
2
|
+
import { Plugin } from 'vite';
|
|
3
|
+
import { UserConfig, UnocssPluginContext, UserConfigDefaults } from '@unocss/core';
|
|
4
|
+
|
|
5
|
+
interface VitePluginConfig<Theme extends object = object> extends UserConfig<Theme> {
|
|
6
|
+
/**
|
|
7
|
+
* Enable UnoCSS inspector
|
|
8
|
+
*
|
|
9
|
+
* @default true
|
|
10
|
+
*/
|
|
11
|
+
inspector?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* CSS Generation mode
|
|
14
|
+
*
|
|
15
|
+
* - `global` - generate a single CSS sheet for entire App
|
|
16
|
+
* - `dist-chunk` - generate a CSS sheet for each code chunk on build, great for MPA
|
|
17
|
+
* - `per-module` - generate a CSS sheet for each module, can be scoped
|
|
18
|
+
* - `vue-scoped` - inject generated CSS to Vue SFC's `<style scoped>` for isolation
|
|
19
|
+
* - `shadow-dom` - inject generated CSS to `Shadow DOM` css style block for each web component
|
|
20
|
+
*
|
|
21
|
+
* @default 'global'
|
|
22
|
+
*/
|
|
23
|
+
mode?: 'global' | 'per-module' | 'vue-scoped' | 'dist-chunk' | 'shadow-dom';
|
|
24
|
+
/**
|
|
25
|
+
* Transform CSS for `@apply` directive
|
|
26
|
+
*
|
|
27
|
+
* @experimental
|
|
28
|
+
* @default false
|
|
29
|
+
*/
|
|
30
|
+
transformCSS?: boolean | 'pre' | 'post';
|
|
31
|
+
/**
|
|
32
|
+
* Make the generated css processed by postcss (https://vitejs.dev/guide/features.html#postcss)
|
|
33
|
+
*
|
|
34
|
+
* @default true
|
|
35
|
+
*/
|
|
36
|
+
postcss?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Use top level await in HMR code to avoid FOUC on dev time.
|
|
39
|
+
*
|
|
40
|
+
* You usually don't need to disable this, unless you are developing on
|
|
41
|
+
* a browser that does not support top level await.
|
|
42
|
+
*
|
|
43
|
+
* This will only affect on dev time.
|
|
44
|
+
*
|
|
45
|
+
* @default true
|
|
46
|
+
*/
|
|
47
|
+
hmrTopLevelAwait?: boolean;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
declare function ChunkModeBuildPlugin({ uno, filter }: UnocssPluginContext): Plugin;
|
|
51
|
+
|
|
52
|
+
declare function GlobalModeDevPlugin({ uno, tokens, tasks, flushTasks, affectedModules, onInvalidate, extract, filter, getConfig }: UnocssPluginContext): Plugin[];
|
|
53
|
+
|
|
54
|
+
declare function GlobalModeBuildPlugin(ctx: UnocssPluginContext<VitePluginConfig>): Plugin[];
|
|
55
|
+
|
|
56
|
+
declare function GlobalModePlugin(ctx: UnocssPluginContext): vite.Plugin[];
|
|
57
|
+
|
|
58
|
+
declare function PerModuleModePlugin({ uno, filter }: UnocssPluginContext): Plugin[];
|
|
59
|
+
|
|
60
|
+
declare function VueScopedPlugin({ uno, ready }: UnocssPluginContext): Plugin;
|
|
61
|
+
|
|
62
|
+
declare function defineConfig<Theme extends object>(config: VitePluginConfig<Theme>): VitePluginConfig<Theme>;
|
|
63
|
+
interface UnocssVitePluginAPI {
|
|
64
|
+
getContext(): UnocssPluginContext<VitePluginConfig>;
|
|
65
|
+
getMode(): VitePluginConfig['mode'];
|
|
66
|
+
}
|
|
67
|
+
declare function UnocssPlugin<Theme extends object>(configOrPath?: VitePluginConfig<Theme> | string, defaults?: UserConfigDefaults): Plugin[];
|
|
68
|
+
|
|
69
|
+
export { ChunkModeBuildPlugin, GlobalModeBuildPlugin, GlobalModeDevPlugin, GlobalModePlugin, PerModuleModePlugin, UnocssVitePluginAPI, VitePluginConfig, VueScopedPlugin, UnocssPlugin as default, defineConfig };
|
package/dist/index.mjs
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import UnocssInspector from '@unocss/inspector';
|
|
2
|
-
import { cssIdRE, createGenerator, BetterMap, notNull, toEscapedSelector } from '@unocss/core';
|
|
3
|
-
import process$1 from 'node:process';
|
|
4
|
-
import { createFilter } from '@rollup/pluginutils';
|
|
5
|
-
import { loadConfig } from '@unocss/config';
|
|
6
|
-
import { createHash } from 'node:crypto';
|
|
7
|
-
import MagicString from 'magic-string';
|
|
8
2
|
import { resolve, isAbsolute, dirname } from 'node:path';
|
|
9
3
|
import fs from 'node:fs/promises';
|
|
10
4
|
import fg from 'fast-glob';
|
|
5
|
+
import MagicString from 'magic-string';
|
|
11
6
|
import remapping from '@ampproject/remapping';
|
|
7
|
+
import { createHash } from 'node:crypto';
|
|
8
|
+
import { cssIdRE, createGenerator, BetterMap, notNull, toEscapedSelector } from '@unocss/core';
|
|
9
|
+
import process$1 from 'node:process';
|
|
12
10
|
import { Buffer } from 'node:buffer';
|
|
11
|
+
import { createFilter } from '@rollup/pluginutils';
|
|
13
12
|
import fs$1 from 'node:fs';
|
|
14
13
|
import { fileURLToPath } from 'node:url';
|
|
14
|
+
import { loadConfig } from '@unocss/config';
|
|
15
15
|
|
|
16
16
|
const defaultPipelineExclude = [cssIdRE];
|
|
17
17
|
const defaultPipelineInclude = [/\.(vue|svelte|[jt]sx|mdx?|astro|elm|php|phtml|html)($|\?)/];
|
|
@@ -459,6 +459,8 @@ function GlobalModeBuildPlugin(ctx) {
|
|
|
459
459
|
distDirs.forEach((dir) => cssPlugins.set(dir, cssPlugin));
|
|
460
460
|
await ready;
|
|
461
461
|
},
|
|
462
|
+
// we inject a hash to chunk before the dist hash calculation to make sure
|
|
463
|
+
// the hash is different when unocss changes
|
|
462
464
|
async renderChunk(_, chunk, options) {
|
|
463
465
|
if (isLegacyChunk(chunk, options))
|
|
464
466
|
return null;
|
|
@@ -523,6 +525,7 @@ function GlobalModeBuildPlugin(ctx) {
|
|
|
523
525
|
name: "unocss:global:build:bundle",
|
|
524
526
|
apply: "build",
|
|
525
527
|
enforce: "post",
|
|
528
|
+
// rewrite the css placeholders
|
|
526
529
|
async generateBundle(options, bundle) {
|
|
527
530
|
const checkJs = ["umd", "amd", "iife"].includes(options.format);
|
|
528
531
|
const files = Object.keys(bundle).filter((i) => i.endsWith(".css") || checkJs && i.endsWith(".js"));
|
|
@@ -717,6 +720,7 @@ function GlobalModeDevPlugin({ uno, tokens, tasks, flushTasks, affectedModules,
|
|
|
717
720
|
return null;
|
|
718
721
|
const { hash, css } = await generateCSS(layer);
|
|
719
722
|
return {
|
|
723
|
+
// add hash to the chunk of CSS that it will send back to client to check if there is new CSS generated
|
|
720
724
|
code: `__uno_hash_${hash}{--:'';}${css}`,
|
|
721
725
|
map: { mappings: "" }
|
|
722
726
|
};
|
|
@@ -988,7 +992,7 @@ function ShadowDomModuleModePlugin({ uno }) {
|
|
|
988
992
|
}
|
|
989
993
|
if (id.includes("?vue&type=style") || id.endsWith(".vue") && vueSFCStyleRE.test(code))
|
|
990
994
|
return code.replace(new RegExp(`(\\/\\*\\s*)?${CSS_PLACEHOLDER}(\\s*\\*\\/)?`), css || "");
|
|
991
|
-
return code.replace(CSS_PLACEHOLDER, css?.replace(/\\/g, "\\\\") ?? "");
|
|
995
|
+
return code.replace(CSS_PLACEHOLDER, css?.replace(/\\/g, "\\\\")?.replace(/`/g, "\\`") ?? "");
|
|
992
996
|
};
|
|
993
997
|
return {
|
|
994
998
|
name: "unocss:shadow-dom",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unocss/vite",
|
|
3
|
-
"version": "0.55.
|
|
3
|
+
"version": "0.55.2",
|
|
4
4
|
"description": "The Vite plugin for UnoCSS",
|
|
5
5
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -43,19 +43,19 @@
|
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@ampproject/remapping": "^2.2.1",
|
|
46
|
-
"@rollup/pluginutils": "^5.0.
|
|
46
|
+
"@rollup/pluginutils": "^5.0.3",
|
|
47
47
|
"chokidar": "^3.5.3",
|
|
48
48
|
"fast-glob": "^3.3.1",
|
|
49
49
|
"magic-string": "^0.30.2",
|
|
50
|
-
"@unocss/config": "0.55.
|
|
51
|
-
"@unocss/core": "0.55.
|
|
52
|
-
"@unocss/inspector": "0.55.
|
|
53
|
-
"@unocss/scope": "0.55.
|
|
54
|
-
"@unocss/transformer-directives": "0.55.
|
|
50
|
+
"@unocss/config": "0.55.2",
|
|
51
|
+
"@unocss/core": "0.55.2",
|
|
52
|
+
"@unocss/inspector": "0.55.2",
|
|
53
|
+
"@unocss/scope": "0.55.2",
|
|
54
|
+
"@unocss/transformer-directives": "0.55.2"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"vite": "^4.4.9",
|
|
58
|
-
"@unocss/shared-integration": "0.55.
|
|
58
|
+
"@unocss/shared-integration": "0.55.2"
|
|
59
59
|
},
|
|
60
60
|
"scripts": {
|
|
61
61
|
"build": "unbuild",
|