@zealakit/css-doctor-vite 0.0.0-stage → 1.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Zealamic
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,68 @@
1
- # Temporary Holding Version
1
+ <div align="center">
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ # @zealakit/css-doctor-vite
4
+
5
+ **Vite/Rollup plugin for page-coverage and size-budget CSS optimization.**
6
+
7
+ [English](https://github.com/zealakit/css-doctor/blob/main/packages/css-doctor-vite/README.md) | [Tiếng Việt](https://github.com/zealakit/css-doctor/blob/main/packages/css-doctor-vite/README_VI.md) | [简体中文](https://github.com/zealakit/css-doctor/blob/main/packages/css-doctor-vite/README_CN.md)
8
+
9
+ </div>
10
+
11
+ ---
12
+
13
+ ![css doctor](https://github.com/zealakit/css-doctor/blob/main/assets/images/css-doctor.jpg)
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ pnpm add -D @zealakit/css-doctor-vite
19
+ ```
20
+
21
+ ## Usage
22
+
23
+ ```ts
24
+ import { defineConfig } from "vite";
25
+ import { cssDoctor } from "@zealakit/css-doctor-vite";
26
+
27
+ export default defineConfig({
28
+ plugins: [
29
+ cssDoctor({
30
+ pageCoverage: {
31
+ enabled: true,
32
+ minPageRatio: 0.5,
33
+ forceCommon: [".app-shell", ".nav-link"],
34
+ },
35
+ sizeBudget: {
36
+ enabled: true,
37
+ maxChunkSize: 40 * 1024,
38
+ isolateVariables: true,
39
+ },
40
+ report: true,
41
+ }),
42
+ ],
43
+ });
44
+ ```
45
+
46
+ ## Options
47
+
48
+ | Option | Default | Description |
49
+ | --- | --- | --- |
50
+ | `pageCoverage.enabled` | `true` | Enable page/class coverage classification. |
51
+ | `pageCoverage.minPageRatio` | `0.5` | Minimum ratio (0.0-1.0) for the common chunk. |
52
+ | `pageCoverage.forceCommon` | `[]` | Selectors or classes forced into common CSS. |
53
+ | `sizeBudget.enabled` | `true` | Enable byte-budget splitting. |
54
+ | `sizeBudget.maxChunkSize` | `60 * 1024` | Maximum bytes per emitted chunk. |
55
+ | `sizeBudget.isolateVariables` | `true` | Extract `:root` and `@theme` variables first. |
56
+ | `minify` | production | Minify emitted CSS with LightningCSS. |
57
+ | `report` | `true` | Print coverage and chunk diagnostics. |
58
+ | `exclude` | CSS Modules safety | Skip matching CSS assets. |
59
+
60
+ ## Safety and limitations
61
+
62
+ - Supports Vite, React, Vue, Svelte, Astro, TanStack Start, and TanStack Router.
63
+ - Lazy route chunks make page coverage effective.
64
+ - CSS Modules and Vue scoped styles are protected; page CSS is loaded by a small page-chunk loader.
65
+
66
+ ## Full documentation
67
+
68
+ Project README: [English](https://github.com/zealakit/css-doctor/blob/main/README.md) | [Tiếng Việt](https://github.com/zealakit/css-doctor/blob/main/README_VI.md) | [简体中文](https://github.com/zealakit/css-doctor/blob/main/README_CN.md)
package/README_CN.md ADDED
@@ -0,0 +1,68 @@
1
+ <div align="center">
2
+
3
+ # @zealakit/css-doctor-vite
4
+
5
+ **用于页面覆盖率与体积预算 CSS 优化的 Vite/Rollup 插件。**
6
+
7
+ [English](https://github.com/zealakit/css-doctor/blob/main/packages/css-doctor-vite/README.md) | [Tiếng Việt](https://github.com/zealakit/css-doctor/blob/main/packages/css-doctor-vite/README_VI.md) | [简体中文](https://github.com/zealakit/css-doctor/blob/main/packages/css-doctor-vite/README_CN.md)
8
+
9
+ </div>
10
+
11
+ ---
12
+
13
+ ![css doctor](https://github.com/zealakit/css-doctor/blob/main/assets/images/css-doctor.jpg)
14
+
15
+ ## 安装
16
+
17
+ ```bash
18
+ pnpm add -D @zealakit/css-doctor-vite
19
+ ```
20
+
21
+ ## 使用
22
+
23
+ ```ts
24
+ import { defineConfig } from "vite";
25
+ import { cssDoctor } from "@zealakit/css-doctor-vite";
26
+
27
+ export default defineConfig({
28
+ plugins: [
29
+ cssDoctor({
30
+ pageCoverage: {
31
+ enabled: true,
32
+ minPageRatio: 0.5,
33
+ forceCommon: [".app-shell", ".nav-link"],
34
+ },
35
+ sizeBudget: {
36
+ enabled: true,
37
+ maxChunkSize: 40 * 1024,
38
+ isolateVariables: true,
39
+ },
40
+ report: true,
41
+ }),
42
+ ],
43
+ });
44
+ ```
45
+
46
+ ## 配置
47
+
48
+ | 参数 | 默认值 | 说明 |
49
+ | --- | --- | --- |
50
+ | `pageCoverage.enabled` | `true` | 启用页面/class 覆盖率分类。 |
51
+ | `pageCoverage.minPageRatio` | `0.5` | 进入 common chunk 的最小比例(0.0-1.0)。 |
52
+ | `pageCoverage.forceCommon` | `[]` | 强制保留在 common CSS 中的 selector/class。 |
53
+ | `sizeBudget.enabled` | `true` | 启用按字节预算分割。 |
54
+ | `sizeBudget.maxChunkSize` | `60 * 1024` | 每个 chunk 的最大字节数。 |
55
+ | `sizeBudget.isolateVariables` | `true` | 先提取 `:root` 与 `@theme` 变量。 |
56
+ | `minify` | production | 使用 LightningCSS 压缩输出 CSS。 |
57
+ | `report` | `true` | 输出覆盖率和 chunk 诊断。 |
58
+ | `exclude` | CSS Modules safety | 跳过匹配的 CSS 资源。 |
59
+
60
+ ## 安全与限制
61
+
62
+ - 支持 Vite、React、Vue、Svelte、Astro、TanStack Start 和 TanStack Router。
63
+ - 懒加载路由 chunk 才能让页面覆盖率分析有效。
64
+ - 保护 CSS Modules 与 Vue scoped styles;页面 CSS 由 page chunk 内的小型 loader 加载。
65
+
66
+ ## 完整文档
67
+
68
+ 项目 README:[English](https://github.com/zealakit/css-doctor/blob/main/README.md) | [Tiếng Việt](https://github.com/zealakit/css-doctor/blob/main/README_VI.md) | [简体中文](https://github.com/zealakit/css-doctor/blob/main/README_CN.md)
package/README_VI.md ADDED
@@ -0,0 +1,68 @@
1
+ <div align="center">
2
+
3
+ # @zealakit/css-doctor-vite
4
+
5
+ **Plugin Vite/Rollup tối ưu CSS theo page coverage và size budget.**
6
+
7
+ [English](https://github.com/zealakit/css-doctor/blob/main/packages/css-doctor-vite/README.md) | [Tiếng Việt](https://github.com/zealakit/css-doctor/blob/main/packages/css-doctor-vite/README_VI.md) | [简体中文](https://github.com/zealakit/css-doctor/blob/main/packages/css-doctor-vite/README_CN.md)
8
+
9
+ </div>
10
+
11
+ ---
12
+
13
+ ![css doctor](https://github.com/zealakit/css-doctor/blob/main/assets/images/css-doctor.jpg)
14
+
15
+ ## Cài đặt
16
+
17
+ ```bash
18
+ pnpm add -D @zealakit/css-doctor-vite
19
+ ```
20
+
21
+ ## Sử dụng
22
+
23
+ ```ts
24
+ import { defineConfig } from "vite";
25
+ import { cssDoctor } from "@zealakit/css-doctor-vite";
26
+
27
+ export default defineConfig({
28
+ plugins: [
29
+ cssDoctor({
30
+ pageCoverage: {
31
+ enabled: true,
32
+ minPageRatio: 0.5,
33
+ forceCommon: [".app-shell", ".nav-link"],
34
+ },
35
+ sizeBudget: {
36
+ enabled: true,
37
+ maxChunkSize: 40 * 1024,
38
+ isolateVariables: true,
39
+ },
40
+ report: true,
41
+ }),
42
+ ],
43
+ });
44
+ ```
45
+
46
+ ## Tùy chọn
47
+
48
+ | Tùy chọn | Mặc định | Mô tả |
49
+ | --- | --- | --- |
50
+ | `pageCoverage.enabled` | `true` | Bật phân loại page/class coverage. |
51
+ | `pageCoverage.minPageRatio` | `0.5` | Tỷ lệ tối thiểu (0.0-1.0) để vào common chunk. |
52
+ | `pageCoverage.forceCommon` | `[]` | Selector/class luôn giữ trong common CSS. |
53
+ | `sizeBudget.enabled` | `true` | Bật chia nhỏ theo byte budget. |
54
+ | `sizeBudget.maxChunkSize` | `60 * 1024` | Số byte tối đa mỗi chunk. |
55
+ | `sizeBudget.isolateVariables` | `true` | Tách biến `:root` và `@theme` trước. |
56
+ | `minify` | production | Minify CSS bằng LightningCSS. |
57
+ | `report` | `true` | In chẩn đoán coverage và chunk. |
58
+ | `exclude` | CSS Modules safety | Bỏ qua asset CSS khớp mẫu. |
59
+
60
+ ## An toàn và giới hạn
61
+
62
+ - Hỗ trợ Vite, React, Vue, Svelte, Astro, TanStack Start và TanStack Router.
63
+ - Lazy route chunk giúp page coverage phát huy tác dụng.
64
+ - CSS Modules và Vue scoped styles được bảo vệ; page CSS được loader nhỏ trong page chunk tải.
65
+
66
+ ## Tài liệu đầy đủ
67
+
68
+ README dự án: [English](https://github.com/zealakit/css-doctor/blob/main/README.md) | [Tiếng Việt](https://github.com/zealakit/css-doctor/blob/main/README_VI.md) | [简体中文](https://github.com/zealakit/css-doctor/blob/main/README_CN.md)