befly-vite 1.4.6 → 1.4.8
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 +17 -11
- package/package.json +4 -4
- package/plugins/auto-import.js +4 -1
- package/plugins/components.js +3 -0
- package/plugins/reactivity-transform.js +16 -1
- package/plugins/router.js +1 -1
package/index.js
CHANGED
|
@@ -107,20 +107,25 @@ export function createBeflyViteConfig(options = {}) {
|
|
|
107
107
|
|
|
108
108
|
const routesFolders = scanViewsInternal(appRoot, addonView);
|
|
109
109
|
|
|
110
|
+
const enableAnalyzer = process.env["ANALYZE"] === "1";
|
|
111
|
+
|
|
112
|
+
/** @type {import('vite').Plugin[]} */
|
|
113
|
+
const plugins = [];
|
|
114
|
+
plugins.push(createRouterPlugin({ routesFolders: routesFolders }));
|
|
115
|
+
plugins.push(createVuePlugin());
|
|
116
|
+
plugins.push(createReactivityTransformPlugin());
|
|
117
|
+
plugins.push(createDevToolsPlugin());
|
|
118
|
+
plugins.push(createAutoImportPlugin({ resolvers: resolvers }));
|
|
119
|
+
plugins.push(createComponentsPlugin({ resolvers: resolvers }));
|
|
120
|
+
plugins.push(createIconsPlugin());
|
|
121
|
+
if (enableAnalyzer) {
|
|
122
|
+
plugins.push(createAnalyzerPlugin());
|
|
123
|
+
}
|
|
124
|
+
|
|
110
125
|
const baseConfig = defineConfig({
|
|
111
126
|
base: "./",
|
|
112
127
|
|
|
113
|
-
plugins:
|
|
114
|
-
//
|
|
115
|
-
createRouterPlugin({ routesFolders: routesFolders }),
|
|
116
|
-
createVuePlugin(),
|
|
117
|
-
createReactivityTransformPlugin(),
|
|
118
|
-
createDevToolsPlugin(),
|
|
119
|
-
createAutoImportPlugin({ resolvers: resolvers }),
|
|
120
|
-
createComponentsPlugin({ resolvers: resolvers }),
|
|
121
|
-
createIconsPlugin(),
|
|
122
|
-
createAnalyzerPlugin()
|
|
123
|
-
],
|
|
128
|
+
plugins: plugins,
|
|
124
129
|
|
|
125
130
|
resolve: {
|
|
126
131
|
alias: {
|
|
@@ -138,6 +143,7 @@ export function createBeflyViteConfig(options = {}) {
|
|
|
138
143
|
outDir: "dist",
|
|
139
144
|
assetsDir: "assets",
|
|
140
145
|
sourcemap: false,
|
|
146
|
+
reportCompressedSize: false,
|
|
141
147
|
chunkSizeWarningLimit: 1000,
|
|
142
148
|
commonjsOptions: {
|
|
143
149
|
include: [/node_modules/],
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "befly-vite",
|
|
3
|
-
"version": "1.4.
|
|
4
|
-
"gitHead": "
|
|
3
|
+
"version": "1.4.8",
|
|
4
|
+
"gitHead": "607fe5ea9c06653ec6da8a9e4175d1f9c7b98c13",
|
|
5
5
|
"private": false,
|
|
6
6
|
"description": "Befly Vite 配置预设和插件集合",
|
|
7
7
|
"keywords": [
|
|
@@ -40,13 +40,13 @@
|
|
|
40
40
|
"unplugin-auto-import": "^21.0.0",
|
|
41
41
|
"unplugin-icons": "^23.0.1",
|
|
42
42
|
"unplugin-vue-components": "^31.0.0",
|
|
43
|
-
"unplugin-vue-router": "^0.19.2",
|
|
44
43
|
"vite-bundle-analyzer": "^1.3.1",
|
|
45
44
|
"vite-plugin-vue-devtools": "^8.0.5"
|
|
46
45
|
},
|
|
47
46
|
"peerDependencies": {
|
|
48
47
|
"vite": "^8.0.0-beta.8",
|
|
49
|
-
"vue": "^3.5.
|
|
48
|
+
"vue": "^3.5.27",
|
|
49
|
+
"vue-router": "^5.0.0-beta.0"
|
|
50
50
|
},
|
|
51
51
|
"engines": {
|
|
52
52
|
"bun": ">=1.3.0"
|
package/plugins/auto-import.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import AutoImport from "unplugin-auto-import/vite";
|
|
2
2
|
import { TDesignResolver } from "unplugin-vue-components/resolvers";
|
|
3
|
-
import { VueRouterAutoImports } from "
|
|
3
|
+
import { VueRouterAutoImports } from "vue-router/unplugin";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* 创建自动导入插件配置
|
|
@@ -9,6 +9,9 @@ export function createAutoImportPlugin(options = {}) {
|
|
|
9
9
|
const { resolvers = {} } = options;
|
|
10
10
|
|
|
11
11
|
return AutoImport({
|
|
12
|
+
// 只给 admin 自身源码做自动导入;addon 视图强制手动导入
|
|
13
|
+
include: [/[\\/]src[\\/].*\.(vue|ts|tsx)$/],
|
|
14
|
+
exclude: [/[\\/]packages[\\/].*[\\/](adminViews|appViews)[\\/]/, /[\\/]node_modules[\\/]@befly-addon[\\/].*[\\/](adminViews|appViews)[\\/]/],
|
|
12
15
|
imports: ["vue", "pinia", VueRouterAutoImports],
|
|
13
16
|
resolvers: [
|
|
14
17
|
TDesignResolver({
|
package/plugins/components.js
CHANGED
|
@@ -9,6 +9,9 @@ export function createComponentsPlugin(options = {}) {
|
|
|
9
9
|
const { resolvers = {} } = options;
|
|
10
10
|
|
|
11
11
|
return Components({
|
|
12
|
+
// 只给 admin 自身源码做组件自动注册;addon 视图强制手动导入
|
|
13
|
+
include: [/[\\/]src[\\/].*\.vue$/],
|
|
14
|
+
exclude: [/[\\/]packages[\\/].*[\\/](adminViews|appViews)[\\/]/, /[\\/]node_modules[\\/]@befly-addon[\\/].*[\\/](adminViews|appViews)[\\/]/],
|
|
12
15
|
resolvers: [
|
|
13
16
|
TDesignResolver({
|
|
14
17
|
library: "vue-next"
|
|
@@ -3,6 +3,21 @@ import ReactivityTransform from "@vue-macros/reactivity-transform/vite";
|
|
|
3
3
|
// 创建 Vue Reactivity Transform 插件配置
|
|
4
4
|
export function createReactivityTransformPlugin() {
|
|
5
5
|
return ReactivityTransform({
|
|
6
|
-
|
|
6
|
+
// 仅处理源码,避免扫描 node_modules/dist 等导致编译耗时暴涨
|
|
7
|
+
include: [
|
|
8
|
+
// Vite 对 .vue SFC 子模块会追加 query(如 ?vue&type=script),因此需要允许可选 query
|
|
9
|
+
/[\\/]src[\\/].*\.(vue|ts|tsx)(\?.*)?$/,
|
|
10
|
+
// workspace 内的 addon 视图(如 packages/addonAdmin/adminViews)属于源码,需要宏转换
|
|
11
|
+
/[\\/]packages[\\/].*[\\/](adminViews|appViews)[\\/].*\.vue(\?.*)?$/,
|
|
12
|
+
// node_modules 内的 @befly-addon 视图也属于源码,需要宏转换
|
|
13
|
+
/[\\/]node_modules[\\/]@befly-addon[\\/].*[\\/](adminViews|appViews)[\\/].*\.vue(\?.*)?$/
|
|
14
|
+
],
|
|
15
|
+
exclude: [
|
|
16
|
+
// 排除绝大多数 node_modules,但保留 @befly-addon(其内部视图属于源码,需要宏转换)
|
|
17
|
+
/[\\/]node_modules[\\/](?!@befly-addon[\\/])/,
|
|
18
|
+
/[\\/]dist[\\/]/,
|
|
19
|
+
/[\\/]temp[\\/]/,
|
|
20
|
+
/[\\/]\.git[\\/]/
|
|
21
|
+
]
|
|
7
22
|
});
|
|
8
23
|
}
|
package/plugins/router.js
CHANGED