befly-vite 1.0.1 → 1.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/index.js +51 -20
- package/package.json +3 -2
package/index.js
CHANGED
|
@@ -15,49 +15,56 @@ import { createInspectPlugin } from './plugins/inspect.js';
|
|
|
15
15
|
* 默认分包策略
|
|
16
16
|
*/
|
|
17
17
|
function defaultManualChunks(id) {
|
|
18
|
-
// Vue
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
// Vue 生态系统 - 使用更严格的匹配确保独立打包
|
|
19
|
+
// 注意:必须在 befly-addon 之前判断,因为 addon 会引用这些库
|
|
20
|
+
|
|
21
|
+
// vue-router(优先级最高)
|
|
22
|
+
if (id.match(/node_modules[\/\\]vue-router[\/\\]/)) {
|
|
23
|
+
return 'vue-router';
|
|
21
24
|
}
|
|
22
|
-
|
|
23
|
-
|
|
25
|
+
|
|
26
|
+
// pinia
|
|
27
|
+
if (id.match(/node_modules[\/\\]pinia[\/\\]/)) {
|
|
28
|
+
return 'pinia';
|
|
24
29
|
}
|
|
25
|
-
|
|
26
|
-
|
|
30
|
+
|
|
31
|
+
// vue 核心和运行时(@vue/* 包)
|
|
32
|
+
if (id.match(/node_modules[\/\\](vue[\/\\]|@vue[\/\\])/)) {
|
|
33
|
+
return 'vue';
|
|
27
34
|
}
|
|
28
35
|
|
|
29
36
|
// TDesign Vue Next
|
|
30
|
-
if (id.includes('
|
|
37
|
+
if (id.includes('tdesign-vue-next')) {
|
|
31
38
|
return 'tdesign';
|
|
32
39
|
}
|
|
33
40
|
|
|
34
41
|
// 工具库
|
|
35
|
-
if (id.
|
|
36
|
-
return '
|
|
42
|
+
if (id.match(/node_modules[\/\\]axios[\/\\]/)) {
|
|
43
|
+
return 'axios';
|
|
37
44
|
}
|
|
38
|
-
if (id.
|
|
39
|
-
return '
|
|
45
|
+
if (id.match(/node_modules[\/\\]lodash-es[\/\\]/)) {
|
|
46
|
+
return 'lodash';
|
|
40
47
|
}
|
|
41
48
|
|
|
42
49
|
// echarts
|
|
43
|
-
if (id.
|
|
44
|
-
return '
|
|
50
|
+
if (id.match(/node_modules[\/\\]echarts[\/\\]/)) {
|
|
51
|
+
return 'echarts';
|
|
45
52
|
}
|
|
46
|
-
if (id.
|
|
47
|
-
return '
|
|
53
|
+
if (id.match(/node_modules[\/\\]zrender[\/\\]/)) {
|
|
54
|
+
return 'zrender';
|
|
48
55
|
}
|
|
49
56
|
|
|
50
57
|
// 图标
|
|
51
|
-
if (id.includes('
|
|
58
|
+
if (id.includes('/@iconify/') || id.includes('~icons/')) {
|
|
52
59
|
return 'icons';
|
|
53
60
|
}
|
|
54
61
|
|
|
55
62
|
// Vue Macros
|
|
56
|
-
if (id.
|
|
63
|
+
if (id.match(/node_modules[\/\\](@vue-macros|vue-macros)[\/\\]/)) {
|
|
57
64
|
return 'vue-macros';
|
|
58
65
|
}
|
|
59
66
|
|
|
60
|
-
// befly-addon
|
|
67
|
+
// befly-addon(必须在 Vue 判断之后)
|
|
61
68
|
if (id.includes('@befly-addon/') || id.includes('packages/addonAdmin/') || id.includes('packages\\addonAdmin\\')) {
|
|
62
69
|
return 'befly-addon';
|
|
63
70
|
}
|
|
@@ -119,12 +126,36 @@ export function createBeflyViteConfig(options = {}) {
|
|
|
119
126
|
sourcemap: false,
|
|
120
127
|
minify: 'esbuild',
|
|
121
128
|
chunkSizeWarningLimit: 1000,
|
|
129
|
+
commonjsOptions: {
|
|
130
|
+
include: [/node_modules/],
|
|
131
|
+
transformMixedEsModules: true
|
|
132
|
+
},
|
|
122
133
|
rollupOptions: {
|
|
123
134
|
output: {
|
|
124
135
|
chunkFileNames: 'assets/js/[name]-[hash].js',
|
|
125
136
|
entryFileNames: 'assets/js/[name]-[hash].js',
|
|
126
137
|
assetFileNames: 'assets/[ext]/[name]-[hash].[ext]',
|
|
127
|
-
manualChunks
|
|
138
|
+
manualChunks(id) {
|
|
139
|
+
// 最高优先级:框架库必须单独打包
|
|
140
|
+
if (id.includes('node_modules')) {
|
|
141
|
+
// vue-router
|
|
142
|
+
if (id.includes('/vue-router/')) return 'vue-router';
|
|
143
|
+
// pinia
|
|
144
|
+
if (id.includes('/pinia/')) return 'pinia';
|
|
145
|
+
// vue 核心(包括 @vue/*)
|
|
146
|
+
if (id.includes('/vue/') || id.includes('/@vue/')) return 'vue';
|
|
147
|
+
// tdesign
|
|
148
|
+
if (id.includes('/tdesign-vue-next/')) return 'tdesign';
|
|
149
|
+
// axios
|
|
150
|
+
if (id.includes('/axios/')) return 'axios';
|
|
151
|
+
// 其他第三方库
|
|
152
|
+
return 'vendor';
|
|
153
|
+
}
|
|
154
|
+
// befly-addon(workspace 包)
|
|
155
|
+
if (id.includes('@befly-addon/') || id.includes('/addonAdmin/')) {
|
|
156
|
+
return 'befly-addon';
|
|
157
|
+
}
|
|
158
|
+
}
|
|
128
159
|
}
|
|
129
160
|
}
|
|
130
161
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "befly-vite",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
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
|
+
"sass": "^1.94.0",
|
|
40
41
|
"unocss": "^66.5.6",
|
|
41
42
|
"unplugin-auto-import": "^20.2.0",
|
|
42
43
|
"unplugin-icons": "^22.5.0",
|
|
@@ -54,5 +55,5 @@
|
|
|
54
55
|
"engines": {
|
|
55
56
|
"bun": ">=1.3.0"
|
|
56
57
|
},
|
|
57
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "784849eea6ddee5491efbad70a9f829a4b6e77f5"
|
|
58
59
|
}
|