befly-vite 1.0.2 → 1.0.3
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 +1 -10
- package/package.json +2 -2
- package/plugins/icons.js +1 -1
- package/plugins/router.js +3 -2
- package/utils/{scanBeflyAddonViews.js → scanBeflyViews.js} +16 -4
package/index.js
CHANGED
|
@@ -160,15 +160,6 @@ export function createBeflyViteConfig(options = {}) {
|
|
|
160
160
|
}
|
|
161
161
|
},
|
|
162
162
|
|
|
163
|
-
css: {
|
|
164
|
-
preprocessorOptions: {
|
|
165
|
-
scss: {
|
|
166
|
-
api: 'modern-compiler',
|
|
167
|
-
additionalData: `@use "@/styles/variables.scss" as *;`
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
},
|
|
171
|
-
|
|
172
163
|
optimizeDeps: {
|
|
173
164
|
include: ['vue', 'vue-router', 'pinia', 'axios', 'tdesign-vue-next']
|
|
174
165
|
}
|
|
@@ -181,7 +172,7 @@ export function createBeflyViteConfig(options = {}) {
|
|
|
181
172
|
export { createUnoConfig } from './configs/uno.config.js';
|
|
182
173
|
|
|
183
174
|
// 导出工具函数
|
|
184
|
-
export {
|
|
175
|
+
export { scanBeflyViews } from './utils/scanBeflyViews.js';
|
|
185
176
|
|
|
186
177
|
// 导出所有插件创建函数(供高级用户自定义)
|
|
187
178
|
export { createVuePlugins } from './plugins/vue.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "befly-vite",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "Befly Vite 配置预设和插件集合",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -55,5 +55,5 @@
|
|
|
55
55
|
"engines": {
|
|
56
56
|
"bun": ">=1.3.0"
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "afb329b2cce2ab5f5821d8515ae7dba4622a4f1f"
|
|
59
59
|
}
|
package/plugins/icons.js
CHANGED
package/plugins/router.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import VueRouter from 'unplugin-vue-router/vite';
|
|
2
|
+
import { scanBeflyViews } from '../utils/scanBeflyViews.js';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* 创建路由插件配置
|
|
5
6
|
*/
|
|
6
7
|
export function createRouterPlugin(options = {}) {
|
|
7
|
-
const { scanViews } = options;
|
|
8
|
+
const { scanViews = scanBeflyViews } = options;
|
|
8
9
|
|
|
9
10
|
return VueRouter({
|
|
10
|
-
routesFolder: scanViews
|
|
11
|
+
routesFolder: scanViews(),
|
|
11
12
|
dts: './src/types/typed-router.d.ts',
|
|
12
13
|
extensions: ['.vue'],
|
|
13
14
|
importMode: 'async',
|
|
@@ -2,17 +2,28 @@ import { readdirSync, existsSync } from 'node:fs';
|
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* 扫描项目和所有 @befly-addon 包的 views 目录
|
|
6
6
|
* 用于 unplugin-vue-router 的 routesFolder 配置
|
|
7
|
-
*
|
|
7
|
+
* 注意:此函数只能在 vite.config.js 中使用(Node.js 环境),不能在浏览器中使用
|
|
8
8
|
* @returns 路由文件夹配置数组
|
|
9
9
|
*/
|
|
10
|
-
export function
|
|
10
|
+
export function scanBeflyViews() {
|
|
11
11
|
// 使用绝对路径:基于项目根目录(process.cwd())
|
|
12
12
|
const projectRoot = process.cwd();
|
|
13
13
|
const addonBasePath = join(projectRoot, 'node_modules', '@befly-addon');
|
|
14
14
|
const routesFolders = [];
|
|
15
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 目录
|
|
16
27
|
if (!existsSync(addonBasePath)) {
|
|
17
28
|
return routesFolders;
|
|
18
29
|
}
|
|
@@ -31,7 +42,8 @@ export function scanBeflyAddonViews() {
|
|
|
31
42
|
if (existsSync(viewsPath)) {
|
|
32
43
|
routesFolders.push({
|
|
33
44
|
src: viewsPath,
|
|
34
|
-
path: `addon/${addonName}
|
|
45
|
+
path: `addon/${addonName}/`,
|
|
46
|
+
exclude: ['**/components/**']
|
|
35
47
|
});
|
|
36
48
|
}
|
|
37
49
|
}
|