@uni_toolkit/vite-plugin-component-config 0.0.1-alpha.1760175691074 → 0.0.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/README.md +85 -0
- package/package.json +9 -2
package/README.md
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# @uni_toolkit/vite-plugin-component-config
|
|
2
|
+
|
|
3
|
+
一个用于 UniApp 项目的 Vite 插件,用于处理 Vue 文件中的 `<component-config>` 标签,将配置提取并合并到对应的 `小程序 JSON 文件` 中。
|
|
4
|
+
|
|
5
|
+
## 功能特性
|
|
6
|
+
|
|
7
|
+
- 🎯 **配置提取**:从 Vue 文件的 `<component-config>` 标签中提取 JSON 配置
|
|
8
|
+
- 🔄 **自动合并**:将提取的配置自动合并到对应的 JSON 文件中
|
|
9
|
+
- 🎨 **文件过滤**:支持自定义文件匹配规则
|
|
10
|
+
- 🚀 **小程序优化**:专为小程序环境设计,只在 `mp-` 平台下生效
|
|
11
|
+
- 📦 **零侵入**:不修改原始 Vue 文件,保持代码完整性
|
|
12
|
+
|
|
13
|
+
## 安装
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install @uni_toolkit/vite-plugin-component-config -D
|
|
17
|
+
# 或
|
|
18
|
+
pnpm add @uni_toolkit/vite-plugin-component-config -D
|
|
19
|
+
# 或
|
|
20
|
+
yarn add @uni_toolkit/vite-plugin-component-config -D
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## 使用方法
|
|
24
|
+
|
|
25
|
+
### 配置 vite.config.js
|
|
26
|
+
|
|
27
|
+
```javascript
|
|
28
|
+
// vite.config.js
|
|
29
|
+
import { defineConfig } from 'vite'
|
|
30
|
+
import uni from '@dcloudio/vite-plugin-uni'
|
|
31
|
+
import componentConfig from '@uni_toolkit/vite-plugin-component-config'
|
|
32
|
+
|
|
33
|
+
export default defineConfig({
|
|
34
|
+
plugins: [
|
|
35
|
+
componentConfig(), // 在 uni 插件之前调用
|
|
36
|
+
uni(),
|
|
37
|
+
]
|
|
38
|
+
})
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### 修改 Vue 文件
|
|
42
|
+
|
|
43
|
+
```vue
|
|
44
|
+
<template>
|
|
45
|
+
<view class="container">
|
|
46
|
+
<text>Hello World</text>
|
|
47
|
+
</view>
|
|
48
|
+
</template>
|
|
49
|
+
|
|
50
|
+
<script>
|
|
51
|
+
export default {
|
|
52
|
+
name: 'MyComponent'
|
|
53
|
+
}
|
|
54
|
+
</script>
|
|
55
|
+
|
|
56
|
+
<component-config>
|
|
57
|
+
// 此处必须是标准的 json 对象
|
|
58
|
+
{
|
|
59
|
+
"usingComponents": {
|
|
60
|
+
"custom-button": "/components/custom-button"
|
|
61
|
+
},
|
|
62
|
+
"componentPlaceholder": {
|
|
63
|
+
"test": "view",
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
</component-config>
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## 配置选项
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
interface ComponentConfigPluginOptions {
|
|
73
|
+
include?: FilterPattern; // 包含的文件模式,默认: ["**/*.{vue,nvue,uvue}"]
|
|
74
|
+
exclude?: FilterPattern; // 排除的文件模式,默认: []
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## 注意事项
|
|
79
|
+
|
|
80
|
+
1. **平台限制**:插件只在小程序环境下生效
|
|
81
|
+
2. **JSON 格式**:`<component-config>` 标签内的内容必须是有效的 JSON 格式
|
|
82
|
+
|
|
83
|
+
## 许可证
|
|
84
|
+
|
|
85
|
+
[MIT](/LICENSE)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uni_toolkit/vite-plugin-component-config",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "chouchouji <1305974212@qq.com>",
|
|
6
6
|
"type": "module",
|
|
@@ -14,6 +14,13 @@
|
|
|
14
14
|
"publishConfig": {
|
|
15
15
|
"access": "public"
|
|
16
16
|
},
|
|
17
|
+
"homepage": "https://github.com/uni-toolkit/uni-toolkit/tree/main/packages/vite-plugin-component-config",
|
|
18
|
+
"bugs": "https://github.com/uni-toolkit/uni-toolkit/issues",
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "https://github.com/uni-toolkit/uni-toolkit.git",
|
|
22
|
+
"directory": "packages/vite-plugin-component-config"
|
|
23
|
+
},
|
|
17
24
|
"main": "dist/index.cjs",
|
|
18
25
|
"module": "dist/index.js",
|
|
19
26
|
"types": "dist/index.d.ts",
|
|
@@ -24,7 +31,7 @@
|
|
|
24
31
|
"@dcloudio/uni-cli-shared": "3.0.0-alpha-4080120250820001",
|
|
25
32
|
"vite": "^7.1.7",
|
|
26
33
|
"@rollup/pluginutils": "^5.3.0",
|
|
27
|
-
"@uni_toolkit/shared": "0.0.
|
|
34
|
+
"@uni_toolkit/shared": "0.0.2"
|
|
28
35
|
},
|
|
29
36
|
"devDependencies": {
|
|
30
37
|
"typescript": "5.3.3",
|