befly-vite 1.0.3 → 1.0.4
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/index.js +0 -3
- package/package.json +3 -2
- package/plugins/router.js +1 -2
- package/utils/scanBeflyViews.js +0 -55
package/index.js
CHANGED
|
@@ -171,9 +171,6 @@ export function createBeflyViteConfig(options = {}) {
|
|
|
171
171
|
// 导出 UnoCSS 配置创建函数
|
|
172
172
|
export { createUnoConfig } from './configs/uno.config.js';
|
|
173
173
|
|
|
174
|
-
// 导出工具函数
|
|
175
|
-
export { scanBeflyViews } from './utils/scanBeflyViews.js';
|
|
176
|
-
|
|
177
174
|
// 导出所有插件创建函数(供高级用户自定义)
|
|
178
175
|
export { createVuePlugins } from './plugins/vue.js';
|
|
179
176
|
export { createRouterPlugin } from './plugins/router.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "befly-vite",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "Befly Vite 配置预设和插件集合",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
"@unocss/preset-uno": "^66.5.6",
|
|
38
38
|
"@vitejs/plugin-vue": "^6.0.1",
|
|
39
39
|
"@vue-macros/reactivity-transform": "^3.1.1",
|
|
40
|
+
"befly-util": "0.1.2",
|
|
40
41
|
"sass": "^1.94.0",
|
|
41
42
|
"unocss": "^66.5.6",
|
|
42
43
|
"unplugin-auto-import": "^20.2.0",
|
|
@@ -55,5 +56,5 @@
|
|
|
55
56
|
"engines": {
|
|
56
57
|
"bun": ">=1.3.0"
|
|
57
58
|
},
|
|
58
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "e43aefa3abeda7a35669778793d39b23b4180c4e"
|
|
59
60
|
}
|
package/plugins/router.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import VueRouter from 'unplugin-vue-router/vite';
|
|
2
|
-
import { scanBeflyViews } from '../utils/scanBeflyViews.js';
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* 创建路由插件配置
|
|
6
5
|
*/
|
|
7
6
|
export function createRouterPlugin(options = {}) {
|
|
8
|
-
const { scanViews
|
|
7
|
+
const { scanViews } = options;
|
|
9
8
|
|
|
10
9
|
return VueRouter({
|
|
11
10
|
routesFolder: scanViews(),
|
package/utils/scanBeflyViews.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { readdirSync, existsSync } from 'node:fs';
|
|
2
|
-
import { join } from 'node:path';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* 扫描项目和所有 @befly-addon 包的 views 目录
|
|
6
|
-
* 用于 unplugin-vue-router 的 routesFolder 配置
|
|
7
|
-
* 注意:此函数只能在 vite.config.js 中使用(Node.js 环境),不能在浏览器中使用
|
|
8
|
-
* @returns 路由文件夹配置数组
|
|
9
|
-
*/
|
|
10
|
-
export function scanBeflyViews() {
|
|
11
|
-
// 使用绝对路径:基于项目根目录(process.cwd())
|
|
12
|
-
const projectRoot = process.cwd();
|
|
13
|
-
const addonBasePath = join(projectRoot, 'node_modules', '@befly-addon');
|
|
14
|
-
const routesFolders = [];
|
|
15
|
-
|
|
16
|
-
// 1. 先添加项目自己的 views 目录
|
|
17
|
-
const projectViewsPath = join(projectRoot, 'src', 'views');
|
|
18
|
-
if (existsSync(projectViewsPath)) {
|
|
19
|
-
routesFolders.push({
|
|
20
|
-
src: projectViewsPath,
|
|
21
|
-
path: '',
|
|
22
|
-
exclude: ['**/components/**']
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// 2. 扫描 @befly-addon 包的 views 目录
|
|
27
|
-
if (!existsSync(addonBasePath)) {
|
|
28
|
-
return routesFolders;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
try {
|
|
32
|
-
const addonDirs = readdirSync(addonBasePath);
|
|
33
|
-
|
|
34
|
-
for (const addonName of addonDirs) {
|
|
35
|
-
const addonPath = join(addonBasePath, addonName);
|
|
36
|
-
|
|
37
|
-
// 检查是否为目录(包括符号链接)
|
|
38
|
-
if (!existsSync(addonPath)) continue;
|
|
39
|
-
|
|
40
|
-
const viewsPath = join(addonPath, 'views');
|
|
41
|
-
|
|
42
|
-
if (existsSync(viewsPath)) {
|
|
43
|
-
routesFolders.push({
|
|
44
|
-
src: viewsPath,
|
|
45
|
-
path: `addon/${addonName}/`,
|
|
46
|
-
exclude: ['**/components/**']
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
} catch (error) {
|
|
51
|
-
console.error('扫描 @befly-addon 目录失败:', error);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return routesFolders;
|
|
55
|
-
}
|