befly-vite 1.1.13 → 1.2.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/index.js CHANGED
@@ -91,7 +91,7 @@ export function createBeflyViteConfig(options = {}) {
91
91
  const { root, scanViews, resolvers = {}, manualChunks, userConfig = {} } = options;
92
92
 
93
93
  // 计算根目录(如果未提供)
94
- const projectRoot = root || process.cwd();
94
+ const appRoot = root || process.cwd();
95
95
 
96
96
  const baseConfig = defineConfig({
97
97
  base: "./",
@@ -112,7 +112,7 @@ export function createBeflyViteConfig(options = {}) {
112
112
 
113
113
  resolve: {
114
114
  alias: {
115
- "@": fileURLToPath(new URL("src", `file:///${projectRoot.replace(/\\/g, "/")}/`))
115
+ "@": fileURLToPath(new URL("src", `file:///${appRoot.replace(/\\/g, "/")}/`))
116
116
  }
117
117
  },
118
118
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "befly-vite",
3
- "version": "1.1.13",
4
- "gitHead": "3a0df4a847cf3da97bb2d09455fabba62027e6c0",
3
+ "version": "1.2.0",
4
+ "gitHead": "faa8189c7d23cf45885c03d1425cba8f5bf45df9",
5
5
  "private": false,
6
6
  "description": "Befly Vite 配置预设和插件集合",
7
7
  "keywords": [
@@ -32,13 +32,17 @@
32
32
  "access": "public",
33
33
  "registry": "https://registry.npmjs.org"
34
34
  },
35
+ "scripts": {
36
+ "scanViewsDir": "bun ./bin/scanViewsDir.ts"
37
+ },
35
38
  "dependencies": {
36
- "@unocss/preset-attributify": "^66.5.10",
37
- "@unocss/preset-uno": "^66.5.10",
39
+ "@unocss/preset-attributify": "^66.5.11",
40
+ "@unocss/preset-uno": "^66.5.11",
38
41
  "@vitejs/plugin-vue": "^6.0.3",
39
42
  "@vue-macros/reactivity-transform": "^3.1.1",
40
- "sass": "^1.96.0",
41
- "unocss": "^66.5.10",
43
+ "befly-shared": "1.0.0",
44
+ "sass": "^1.97.1",
45
+ "unocss": "^66.5.11",
42
46
  "unplugin-auto-import": "^20.3.0",
43
47
  "unplugin-icons": "^22.5.0",
44
48
  "unplugin-vue-components": "^30.0.0",
@@ -48,7 +52,7 @@
48
52
  "vite-plugin-vue-devtools": "^8.0.5"
49
53
  },
50
54
  "peerDependencies": {
51
- "vite": "^8.0.0-beta.3",
55
+ "vite": "^8.0.0-beta.5",
52
56
  "vue": "^3.5.26"
53
57
  },
54
58
  "engines": {
@@ -2,29 +2,33 @@ import { existsSync, readdirSync, realpathSync } from "node:fs";
2
2
  import { join } from "node:path";
3
3
 
4
4
  /**
5
- * 扫描项目和所有 @befly-addon 包的 views 目录
5
+ * 扫描项目和所有 @befly-addon 包的视图目录
6
6
  * 用于 unplugin-vue-router 的 routesFolder 配置
7
+ *
8
+ * 约定:addon 只允许从 adminViews 扫描路由:
9
+ * - <addonRoot>/adminViews
10
+ *
7
11
  * 注意:此函数只能在 vite.config.js 中使用(Node.js 环境),不能在浏览器中使用
8
12
  * @returns {Array<{ src: string, path: string, exclude: string[] }>} 路由文件夹配置数组
9
13
  */
10
14
  export function scanViews() {
11
- const projectRoot = process.cwd();
12
- const addonBasePath = join(projectRoot, "node_modules", "@befly-addon");
15
+ const appRoot = process.cwd();
16
+ const addonBasePath = join(appRoot, "node_modules", "@befly-addon");
13
17
 
14
18
  /** @type {Array<{ src: string, path: string, exclude: string[] }>} */
15
19
  const routesFolders = [];
16
20
 
17
21
  // 1. 项目自身 views
18
- const projectViewsPath = join(projectRoot, "src", "views");
19
- if (existsSync(projectViewsPath)) {
22
+ const appViewsPath = join(appRoot, "src", "views");
23
+ if (existsSync(appViewsPath)) {
20
24
  routesFolders.push({
21
- src: realpathSync(projectViewsPath),
25
+ src: realpathSync(appViewsPath),
22
26
  path: "",
23
27
  exclude: ["**/components/**"]
24
28
  });
25
29
  }
26
30
 
27
- // 2. 扫描 @befly-addon/*/views
31
+ // 2. 扫描 @befly-addon/*/adminViews(仅此目录允许生成 addon 路由)
28
32
  if (!existsSync(addonBasePath)) {
29
33
  return routesFolders;
30
34
  }
@@ -38,10 +42,10 @@ export function scanViews() {
38
42
  continue;
39
43
  }
40
44
 
41
- const viewsPath = join(addonPath, "views");
42
- if (existsSync(viewsPath)) {
45
+ const adminViewsPath = join(addonPath, "adminViews");
46
+ if (existsSync(adminViewsPath)) {
43
47
  routesFolders.push({
44
- src: realpathSync(viewsPath),
48
+ src: realpathSync(adminViewsPath),
45
49
  path: `addon/${addonName}/`,
46
50
  exclude: ["**/components/**"]
47
51
  });