@slice_cy/mint 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.
Files changed (98) hide show
  1. package/README.md +697 -0
  2. package/app/common/base-response.js +10 -0
  3. package/app/common/business-error.js +10 -0
  4. package/app/common/error-code.js +22 -0
  5. package/app/common/return-utils.js +40 -0
  6. package/app/common/router-schema-validator.js +25 -0
  7. package/app/controller/base.js +24 -0
  8. package/app/controller/project.js +90 -0
  9. package/app/controller/view.js +13 -0
  10. package/app/docs/dsl-doc.js +148 -0
  11. package/app/extend/logger.js +30 -0
  12. package/app/extend/params-valid.js +6 -0
  13. package/app/extend/return-utils.js +9 -0
  14. package/app/middleware/api-sign-verify.js +25 -0
  15. package/app/middleware/err-handler.js +18 -0
  16. package/app/middleware/project-handler.js +25 -0
  17. package/app/pages/boot.js +34 -0
  18. package/app/pages/dashboard/complex-view/header-view/index.vue +108 -0
  19. package/app/pages/dashboard/complex-view/iframe-view/index.vue +37 -0
  20. package/app/pages/dashboard/complex-view/schema-view/complex-view/search-panel/index.vue +36 -0
  21. package/app/pages/dashboard/complex-view/schema-view/complex-view/table-panel/index.vue +123 -0
  22. package/app/pages/dashboard/complex-view/schema-view/components/component-config.js +14 -0
  23. package/app/pages/dashboard/complex-view/schema-view/components/createForm/index.vue +72 -0
  24. package/app/pages/dashboard/complex-view/schema-view/components/detailPanel/index.vue +52 -0
  25. package/app/pages/dashboard/complex-view/schema-view/components/editForm/index.vue +87 -0
  26. package/app/pages/dashboard/complex-view/schema-view/hook/use-schema.js +113 -0
  27. package/app/pages/dashboard/complex-view/schema-view/index.vue +114 -0
  28. package/app/pages/dashboard/complex-view/sider-view/index.vue +116 -0
  29. package/app/pages/dashboard/entry.dashboard.js +44 -0
  30. package/app/pages/dashboard/index.vue +60 -0
  31. package/app/pages/service/index.js +70 -0
  32. package/app/pages/store/index.js +4 -0
  33. package/app/pages/store/menu.js +86 -0
  34. package/app/pages/store/project.js +9 -0
  35. package/app/pages/utils/index.js +26 -0
  36. package/app/pages/widgets/header-container/assets/avatar.png +0 -0
  37. package/app/pages/widgets/header-container/assets/icon.png +0 -0
  38. package/app/pages/widgets/header-container/index.vue +108 -0
  39. package/app/pages/widgets/schema-form/components/input/index.vue +155 -0
  40. package/app/pages/widgets/schema-form/components/input-number/index.vue +148 -0
  41. package/app/pages/widgets/schema-form/components/select/index.vue +132 -0
  42. package/app/pages/widgets/schema-form/form-item-cofnig.js +18 -0
  43. package/app/pages/widgets/schema-form/index.vue +137 -0
  44. package/app/pages/widgets/schema-search-bar/component/date-range-picker/index.vue +55 -0
  45. package/app/pages/widgets/schema-search-bar/component/dynamic-select/index.vue +70 -0
  46. package/app/pages/widgets/schema-search-bar/component/input/index.vue +54 -0
  47. package/app/pages/widgets/schema-search-bar/component/select/index.vue +65 -0
  48. package/app/pages/widgets/schema-search-bar/index.vue +143 -0
  49. package/app/pages/widgets/schema-search-bar/search-item-config.js +20 -0
  50. package/app/pages/widgets/schema-table/index.vue +198 -0
  51. package/app/pages/widgets/sider-container/index.vue +30 -0
  52. package/app/post-router.js +9 -0
  53. package/app/pre-middleware.js +37 -0
  54. package/app/public/dist/entry.dashboard.tpl +2 -0
  55. package/app/public/dist/entry.project-list.tpl +2 -0
  56. package/app/public/dist/prod/css/async.609.bcbe5779.css +1 -0
  57. package/app/public/dist/prod/css/async.952.9bc7c180.css +1 -0
  58. package/app/public/dist/prod/css/common.1a98227b.css +1 -0
  59. package/app/public/dist/prod/css/entry.project-list.14f64dd9.css +1 -0
  60. package/app/public/dist/prod/js/142.56646c73.bundle.js +1 -0
  61. package/app/public/dist/prod/js/609.8270b20d.bundle.js +1 -0
  62. package/app/public/dist/prod/js/68.2813fafe.bundle.js +1 -0
  63. package/app/public/dist/prod/js/952.c76c04fb.bundle.js +1 -0
  64. package/app/public/dist/prod/js/common.9985f827.bundle.js +1 -0
  65. package/app/public/dist/prod/js/entry.dashboard.cd7591e4.bundle.js +1 -0
  66. package/app/public/dist/prod/js/entry.project-list.beb0fa9d.bundle.js +1 -0
  67. package/app/public/dist/prod/js/runtime.5602b906.bundle.js +1 -0
  68. package/app/public/dist/prod/js/vendor.709fbf32.bundle.js +53 -0
  69. package/app/public/dist/prod/static/images/avatar.78e68eaa.png +0 -0
  70. package/app/public/dist/static/logo.png +0 -0
  71. package/app/public/dist/static/normalize.css +1 -0
  72. package/app/public/static/logo.png +0 -0
  73. package/app/public/static/normalize.css +267 -0
  74. package/app/router/project.js +6 -0
  75. package/app/router/view.js +5 -0
  76. package/app/router-schema/project.js +14 -0
  77. package/app/service/base.js +22 -0
  78. package/app/service/project.js +49 -0
  79. package/app/view/entry.tpl +18 -0
  80. package/app/webpack/config/webpack.base.js +288 -0
  81. package/app/webpack/config/webpack.dev.js +53 -0
  82. package/app/webpack/config/webpack.prod.js +106 -0
  83. package/app/webpack/dev.js +34 -0
  84. package/app/webpack/libs/block.js +1 -0
  85. package/app/webpack/prod.js +21 -0
  86. package/config/config.default.js +5 -0
  87. package/index.js +37 -0
  88. package/mint-core/env.js +23 -0
  89. package/mint-core/index.js +101 -0
  90. package/mint-core/loader/config.js +59 -0
  91. package/mint-core/loader/controller.js +59 -0
  92. package/mint-core/loader/extend.js +42 -0
  93. package/mint-core/loader/middleware.js +54 -0
  94. package/mint-core/loader/router-schema.js +39 -0
  95. package/mint-core/loader/router.js +36 -0
  96. package/mint-core/loader/service.js +57 -0
  97. package/model/index.js +94 -0
  98. package/package.json +93 -0
Binary file
@@ -0,0 +1 @@
1
+ /*! normalize.css v3.0.2 | MIT License | git.io/normalize */a,b,blockquote,body,button,dd,div,dl,dt,font,form,h1,h2,h3,html,i,iframe,img,input,label,li,ol,p,span,strong,table,tbody,td,ul{list-style:none;margin:0;padding:0}html{font-family:Open Sans,Helvetica Neue,Microsoft Yahei,sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}a{background-color:transparent;text-decoration:none}a:active,a:hover{outline:0}b,strong{font-weight:700}img{border:0}figure{margin:1em 40px}button,input,optgroup,select,textarea{color:inherit;font:inherit;margin:0}button{overflow:visible}button,select{text-transform:none}button,html input[type=button],input[type=reset],input[type=submit]{-webkit-appearance:button;cursor:pointer}button[disabled],html input[disabled]{cursor:default}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}input{line-height:normal}input[type=checkbox],input[type=radio]{box-sizing:border-box;padding:0}input[type=number]::-webkit-inner-spin-button,input[type=number]::-webkit-outer-spin-button{height:auto}input[type=search]{-webkit-appearance:textfield;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box}input[type=search]::-webkit-search-cancel-button,input[type=search]::-webkit-search-decoration{-webkit-appearance:none}table{border-collapse:collapse;border-spacing:0}td,th{padding:0}
Binary file
@@ -0,0 +1,267 @@
1
+ /*! normalize.css v3.0.2 | MIT License | git.io/normalize */
2
+
3
+ /**
4
+ * 1. Set default font family to sans-serif.
5
+ * 2. Prevent iOS text size adjust after orientation change, without disabling
6
+ * user zoom.
7
+ */
8
+ html,
9
+ body,
10
+ span,
11
+ div,
12
+ p,
13
+ a,
14
+ table,
15
+ tbody,
16
+ td,
17
+ h1,
18
+ h2,
19
+ h3,
20
+ img,
21
+ form,
22
+ font,
23
+ strong,
24
+ b,
25
+ i,
26
+ dl,
27
+ dt,
28
+ dd,
29
+ ol,
30
+ ul,
31
+ li,
32
+ dl,
33
+ dd,
34
+ dt,
35
+ iframe,
36
+ label,
37
+ blockquote,
38
+ input,
39
+ button {
40
+ padding: 0;
41
+ margin: 0;
42
+ list-style: none;
43
+ }
44
+
45
+ html {
46
+ font-family: "Open Sans", "Helvetica Neue", "Microsoft Yahei", sans-serif; /* 1 */
47
+ -ms-text-size-adjust: 100%; /* 2 */
48
+ -webkit-text-size-adjust: 100%; /* 2 */
49
+ }
50
+
51
+ /**
52
+ * Remove default margin.
53
+ */
54
+
55
+ body {
56
+ margin: 0;
57
+ }
58
+
59
+ /* Links
60
+ ========================================================================== */
61
+
62
+ /**
63
+ * Remove the gray background color from active links in IE 10.
64
+ */
65
+
66
+ a {
67
+ background-color: transparent;
68
+ text-decoration: none;
69
+ }
70
+
71
+ /**
72
+ * Improve readability when focused and also mouse hovered in all browsers.
73
+ */
74
+
75
+ a:active,
76
+ a:hover {
77
+ outline: 0;
78
+ }
79
+
80
+ /* Text-level semantics
81
+ ========================================================================== */
82
+
83
+ /**
84
+ * Address style set to `bolder` in Firefox 4+, Safari, and Chrome.
85
+ */
86
+
87
+ b,
88
+ strong {
89
+ font-weight: bold;
90
+ }
91
+
92
+ /* Embedded content
93
+ ========================================================================== */
94
+
95
+ /**
96
+ * Remove border when inside `a` element in IE 8/9/10.
97
+ */
98
+
99
+ img {
100
+ border: 0;
101
+ }
102
+
103
+ /* Grouping content
104
+ ========================================================================== */
105
+
106
+ /**
107
+ * Address margin not present in IE 8/9 and Safari.
108
+ */
109
+
110
+ figure {
111
+ margin: 1em 40px;
112
+ }
113
+
114
+ /* Forms
115
+ ========================================================================== */
116
+
117
+ /**
118
+ * Known limitation: by default, Chrome and Safari on OS X allow very limited
119
+ * styling of `select`, unless a `border` property is set.
120
+ */
121
+
122
+ /**
123
+ * 1. Correct color not being inherited.
124
+ a * Known issue: affects color of disabled elements.
125
+ * 2. Correct font properties not being inherited.
126
+ * 3. Address margins set differently in Firefox 4+, Safari, and Chrome.
127
+ */
128
+
129
+ button,
130
+ input,
131
+ optgroup,
132
+ select,
133
+ textarea {
134
+ color: inherit; /* 1 */
135
+ font: inherit; /* 2 */
136
+ margin: 0; /* 3 */
137
+ }
138
+
139
+ /**
140
+ * Address `overflow` set to `hidden` in IE 8/9/10/11.
141
+ */
142
+
143
+ button {
144
+ overflow: visible;
145
+ }
146
+
147
+ /**
148
+ * Address inconsistent `text-transform` inheritance for `button` and `select`.
149
+ * All other form control elements do not inherit `text-transform` values.
150
+ * Correct `button` style inheritance in Firefox, IE 8/9/10/11, and Opera.
151
+ * Correct `select` style inheritance in Firefox.
152
+ */
153
+
154
+ button,
155
+ select {
156
+ text-transform: none;
157
+ }
158
+
159
+ /**
160
+ * 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio`
161
+ * and `video` controls.
162
+ * 2. Correct inability to style clickable `input` types in iOS.
163
+ * 3. Improve usability and consistency of cursor style between image-type
164
+ * `input` and others.
165
+ */
166
+
167
+ button,
168
+ html input[type="button"], /* 1 */
169
+ input[type="reset"],
170
+ input[type="submit"] {
171
+ -webkit-appearance: button; /* 2 */
172
+ cursor: pointer; /* 3 */
173
+ }
174
+
175
+ /**
176
+ * Re-set default cursor for disabled elements.
177
+ */
178
+
179
+ button[disabled],
180
+ html input[disabled] {
181
+ cursor: default;
182
+ }
183
+
184
+ /**
185
+ * Remove inner padding and border in Firefox 4+.
186
+ */
187
+
188
+ button::-moz-focus-inner,
189
+ input::-moz-focus-inner {
190
+ border: 0;
191
+ padding: 0;
192
+ }
193
+
194
+ /**
195
+ * Address Firefox 4+ setting `line-height` on `input` using `!important` in
196
+ * the UA stylesheet.
197
+ */
198
+
199
+ input {
200
+ line-height: normal;
201
+ }
202
+
203
+ /**
204
+ * It's recommended that you don't attempt to style these elements.
205
+ * Firefox's implementation doesn't respect box-sizing, padding, or width.
206
+ *
207
+ * 1. Address box sizing set to `content-box` in IE 8/9/10.
208
+ * 2. Remove excess padding in IE 8/9/10.
209
+ */
210
+
211
+ input[type="checkbox"],
212
+ input[type="radio"] {
213
+ box-sizing: border-box; /* 1 */
214
+ padding: 0; /* 2 */
215
+ }
216
+
217
+ /**
218
+ * Fix the cursor style for Chrome's increment/decrement buttons. For certain
219
+ * `font-size` values of the `input`, it causes the cursor style of the
220
+ * decrement button to change from `default` to `text`.
221
+ */
222
+
223
+ input[type="number"]::-webkit-inner-spin-button,
224
+ input[type="number"]::-webkit-outer-spin-button {
225
+ height: auto;
226
+ }
227
+
228
+ /**
229
+ * 1. Address `appearance` set to `searchfield` in Safari and Chrome.
230
+ * 2. Address `box-sizing` set to `border-box` in Safari and Chrome
231
+ * (include `-moz` to future-proof).
232
+ */
233
+
234
+ input[type="search"] {
235
+ -webkit-appearance: textfield; /* 1 */
236
+ -moz-box-sizing: content-box;
237
+ -webkit-box-sizing: content-box; /* 2 */
238
+ box-sizing: content-box;
239
+ }
240
+
241
+ /**
242
+ * Remove inner padding and search cancel button in Safari and Chrome on OS X.
243
+ * Safari (but not Chrome) clips the cancel button when the search input has
244
+ * padding (and `textfield` appearance).
245
+ */
246
+
247
+ input[type="search"]::-webkit-search-cancel-button,
248
+ input[type="search"]::-webkit-search-decoration {
249
+ -webkit-appearance: none;
250
+ }
251
+
252
+ /* Tables
253
+ ========================================================================== */
254
+
255
+ /**
256
+ * Remove most spacing between table cells.
257
+ */
258
+
259
+ table {
260
+ border-collapse: collapse;
261
+ border-spacing: 0;
262
+ }
263
+
264
+ td,
265
+ th {
266
+ padding: 0;
267
+ }
@@ -0,0 +1,6 @@
1
+ module.exports = (app, router) => {
2
+ const { project: projectController } = app.controller;
3
+ router.get("/api/project/modelList", projectController.getModelList.bind(projectController));
4
+ router.get("/api/project/list", projectController.getProjectList.bind(projectController));
5
+ router.get("/api/project", projectController.getProject.bind(projectController));
6
+ };
@@ -0,0 +1,5 @@
1
+ module.exports = (app, router) => {
2
+ const { view: viewController } = app.controller;
3
+ router.get("/view/:page", viewController.render);
4
+ router.get("/view/:page/*", viewController.render);
5
+ };
@@ -0,0 +1,14 @@
1
+ const { z } = require("zod");
2
+
3
+ module.exports = {
4
+ projectListQueryDTO: {
5
+ get: z.object({
6
+ project_key: z.string().optional(),
7
+ }),
8
+ },
9
+ projectQueryDTO: {
10
+ get: z.object({
11
+ project_key: z.string().nonempty(),
12
+ }),
13
+ },
14
+ };
@@ -0,0 +1,22 @@
1
+ const superAgent = require("superagent");
2
+
3
+ module.exports = (app) => {
4
+ return class BaseService {
5
+ /**
6
+ * Service基类
7
+ * 统一收拢service的通用方法
8
+ */
9
+ constructor() {
10
+ this.curl = superAgent;
11
+ }
12
+
13
+ /**
14
+ * 统一抛出业务错误
15
+ * @param {object|number} businessCode 业务错误码结构体或错误码
16
+ * @param {string} message 自定义错误信息
17
+ */
18
+ throwIf(...args) {
19
+ app.returnUtils.throwIf(...args);
20
+ }
21
+ };
22
+ };
@@ -0,0 +1,49 @@
1
+ const { SYSTEM_ERROR } = require("../common/error-code");
2
+
3
+ module.exports = (app) => {
4
+ const BaseService = require("./base")(app);
5
+ const modelList = require("../../model/index")(app);
6
+ return class ProjectService extends BaseService {
7
+ /**
8
+ * 获取模型列表
9
+ */
10
+ async getModelList() {
11
+ try {
12
+ return modelList;
13
+ } catch {
14
+ return [];
15
+ }
16
+ }
17
+
18
+ /**
19
+ * 获取项目列表(project_key 存在返回同属同一领域模型下的所有项目模型,不存在则返回所有项目模型)
20
+ * @param {string} project_key
21
+ */
22
+ async getProjectList(project_key) {
23
+ return (modelList || []).reduce((pre, cur) => {
24
+ const { project } = cur;
25
+
26
+ if (project_key && !project[project_key]) {
27
+ return pre;
28
+ }
29
+
30
+ for (const key in project) {
31
+ pre.push(project[key]);
32
+ }
33
+ return pre;
34
+ }, []);
35
+ }
36
+
37
+ /**
38
+ * 获取单个项目
39
+ * @param {string} project_key
40
+ */
41
+ async getProject(project_key) {
42
+ let projectConfig;
43
+ const modelItem = modelList.find((item) => item.project[project_key]);
44
+ projectConfig = modelItem?.project?.[project_key];
45
+ this.throwIf(!projectConfig, SYSTEM_ERROR);
46
+ return projectConfig;
47
+ }
48
+ };
49
+ };
@@ -0,0 +1,18 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <link rel="stylesheet" href="/static/normalize.css">
7
+ <link type="image/x-icon" rel="icon" href="/static/logo.png">
8
+ <title>Document</title>
9
+ </head>
10
+ <body>
11
+ <div id="app"></div>
12
+ <input id="project-key" style="display:none" value="{{project_key}}">
13
+ <script type="text/javascript">
14
+ const projectKey = document.getElementById('project-key').value;
15
+ window.projectKey = projectKey;
16
+ </script>
17
+ </body>
18
+ </html>
@@ -0,0 +1,288 @@
1
+ /**
2
+ * 核心思想:
3
+ * 宏观角度:利用工具从入口中开始收集依赖,寻找依赖,编译依赖成对应的文件,输出到指定目录
4
+ * 1.根据约定大于配置,从约定好的pages目录下获取到entry.[].js文件当做是入口,动态生成entry的配置
5
+ * 2.通过模块路径配置,解析配置,输出配置,分包配置,插件配置等行为输出产物到指定目录
6
+ */
7
+
8
+ const path = require("path");
9
+ const fs = require("fs");
10
+ const HtmlWebpackPlugin = require("html-webpack-plugin");
11
+ // const BundleAnalyzerPlugin = require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
12
+ const { mergeWithRules } = require("webpack-merge");
13
+ const { VueLoaderPlugin } = require("vue-loader");
14
+ const webpack = require("webpack");
15
+ const CopyPlugin = require("copy-webpack-plugin");
16
+ const glob = require("glob");
17
+ const { sep } = path;
18
+ const Components = require("unplugin-vue-components/webpack");
19
+ const { AntDesignVueResolver } = require("unplugin-vue-components/resolvers");
20
+
21
+ const templatePath = path.join(__dirname, `..${sep}..${sep}view${sep}entry.tpl`);
22
+ const pageEntries = {};
23
+ const htmlWebpackPluginList = [];
24
+
25
+ /**
26
+ * 定义页面输出的位置
27
+ * @param {string} entryName
28
+ * @returns
29
+ */
30
+ const outputPage = (entryName) => {
31
+ return path.join(process.cwd(), `app${sep}public${sep}dist`, `${entryName}.tpl`);
32
+ };
33
+
34
+ // 在约定大于配置的前提下,从指定目录中获取多页面的入口js
35
+ const handlerFilePath = (filePath, entriesConfig = {}, htmlPluginList = []) => {
36
+ const entryName = path.basename(filePath, ".js");
37
+ entriesConfig[entryName] = filePath;
38
+ // 对每一个入口都构造一个页面文件的生成,推进htmlWebpackPluginList数组中
39
+ const item = new HtmlWebpackPlugin({
40
+ template: templatePath,
41
+ filename: outputPage(entryName),
42
+ chunks: [entryName],
43
+ });
44
+ htmlPluginList.push(item);
45
+ };
46
+
47
+ const businessEntryPath = path.join(process.cwd(), `app${sep}pages${sep}**${sep}entry.*.js`);
48
+ const mintEntryPath = path.join(__dirname, `..${sep}..${sep}pages${sep}**${sep}entry.*.js`);
49
+
50
+ const businessFileList = glob.sync(businessEntryPath);
51
+ const mintFileList = glob.sync(mintEntryPath);
52
+
53
+ mintFileList.forEach((file) => handlerFilePath(file, pageEntries, htmlWebpackPluginList));
54
+ businessFileList.forEach((file) => handlerFilePath(file, pageEntries, htmlWebpackPluginList));
55
+
56
+ const webpackBaseConfig = {
57
+ // 入口配置
58
+ entry: pageEntries,
59
+ // 配置模块解析的方式,决定了要用什么方式去解析模块
60
+ module: {
61
+ rules: [
62
+ // 对js文件配置解析
63
+ {
64
+ test: /\.js$/i,
65
+ include: [businessEntryPath, mintEntryPath],
66
+ use: require.resolve("babel-loader"),
67
+ },
68
+ // 对css文件配置解析
69
+ {
70
+ test: /\.css$/i,
71
+ use: [require.resolve("style-loader"), require.resolve("css-loader")],
72
+ },
73
+ // 对less文件解析
74
+ {
75
+ test: /\.less$/i,
76
+ use: [
77
+ require.resolve("style-loader"),
78
+ require.resolve("css-loader"),
79
+ require.resolve("less-loader"),
80
+ ],
81
+ },
82
+ // 对vue文件进行解析
83
+ {
84
+ test: /\.vue$/i,
85
+ use: require.resolve("vue-loader"),
86
+ },
87
+ // 对图片解析
88
+ {
89
+ test: /\.(png|jpe?g|gif|webp)$/i,
90
+ type: "asset",
91
+ parser: {
92
+ dataUrlCondition: {
93
+ maxSize: 8 * 1024,
94
+ },
95
+ },
96
+ generator: {
97
+ filename: "static/images/[name].[contenthash:8][ext]",
98
+ },
99
+ },
100
+ // 对字体图标进行解析
101
+ {
102
+ test: /\.(woff|woff2|eot|ttf|otf|svg)$/i,
103
+ type: "asset/resource",
104
+ generator: {
105
+ filename: "static/fonts/[name].[contenthash:8][ext]",
106
+ },
107
+ },
108
+ ],
109
+ },
110
+ // 输出配置
111
+ output: {},
112
+ // 配置模块解析的具体行为
113
+ resolve: {
114
+ // 当遇到没后缀的文件引入时,会自动添加后缀
115
+ extensions: [".js", ".vue", ".less", ".css"],
116
+ // 路径别名
117
+ alias: (() => {
118
+ const aliasMap = {};
119
+ const blockPath = path.join(__dirname, `..${sep}libs${sep}block.js`);
120
+ // dashboard路由拓展配置
121
+ const businessDashboartRouterConfig = path.join(
122
+ process.cwd(),
123
+ `app${sep}pages${sep}dashboard${sep}router.js`,
124
+ );
125
+ aliasMap["$businessDashboardRouterConfig"] = fs.existsSync(businessDashboartRouterConfig)
126
+ ? businessDashboartRouterConfig
127
+ : blockPath;
128
+
129
+ // schema-view 动态组件拓展配置
130
+ const businessDashboardComponentConfig = path.join(
131
+ process.cwd(),
132
+ `app${sep}pages${sep}dashboard${sep}schema-view${sep}components${sep}component-cofnig.js`,
133
+ );
134
+
135
+ aliasMap["$businessComponentConfig"] = fs.existsSync(businessDashboardComponentConfig)
136
+ ? businessDashboardComponentConfig
137
+ : blockPath;
138
+
139
+ // schema-form 动态子组件拓展
140
+ const businessFormItemConfig = path.join(
141
+ process.cwd(),
142
+ `app${sep}pages${sep}widgets${sep}schema-form${sep}form-item-cofnig.js`,
143
+ );
144
+ aliasMap["$businessFormItemConfig"] = fs.existsSync(businessFormItemConfig)
145
+ ? businessFormItemConfig
146
+ : blockPath;
147
+
148
+ // schema-search-bar 拓展
149
+ const businessSearchItemConfig = path.join(
150
+ process.cwd(),
151
+ `app${sep}pages${sep}widgets${sep}schema-search-bar${sep}search-item-cofnig.js`,
152
+ );
153
+ aliasMap["$businessSearchItemConfig"] = fs.existsSync(businessSearchItemConfig)
154
+ ? businessSearchItemConfig
155
+ : blockPath;
156
+
157
+ return {
158
+ vue: require.resolve("vue"),
159
+ "ant-design-vue": path.dirname(require.resolve("ant-design-vue/package.json")),
160
+ $mintPage: path.join(__dirname, `..${sep}..${sep}pages`),
161
+ $mintCommon: path.join(__dirname, `..${sep}..${sep}pages${sep}common`),
162
+ $mintService: path.join(__dirname, `..${sep}..${sep}pages${sep}service`),
163
+ $mintWidgets: path.join(__dirname, `..${sep}..${sep}pages${sep}widgets`),
164
+ $mintHeaderContainer: path.join(
165
+ __dirname,
166
+ `..${sep}..${sep}pages${sep}widgets${sep}header-container${sep}index.vue`,
167
+ ),
168
+ $mintSchemaForm: path.join(
169
+ __dirname,
170
+ `..${sep}..${sep}pages${sep}widgets${sep}schema-from${sep}index.vue`,
171
+ ),
172
+ $mintSchemaSearchBar: path.join(
173
+ __dirname,
174
+ `..${sep}..${sep}pages${sep}widgets${sep}schema-search-bar${sep}index.vue`,
175
+ ),
176
+ $mintSchemaTable: path.join(
177
+ __dirname,
178
+ `..${sep}..${sep}pages${sep}widgets${sep}schema-table${sep}index.vue`,
179
+ ),
180
+ $mintSiderContainer: path.join(
181
+ __dirname,
182
+ `..${sep}..${sep}pages${sep}widgets${sep}sider-container${sep}index.vue`,
183
+ ),
184
+ $mintBootstrap: path.join(__dirname, `..${sep}..${sep}pages${sep}boot`),
185
+ $mintStore: path.join(__dirname, `..${sep}..${sep}pages${sep}store`),
186
+ $mintUtils: path.join(__dirname, `..${sep}..${sep}pages${sep}utils`),
187
+ ...aliasMap,
188
+ };
189
+ })(),
190
+ },
191
+ // 优化配置
192
+ optimization: {
193
+ // 将webpack运行时代码抽离成单独的chunk
194
+ runtimeChunk: "single",
195
+ splitChunks: {
196
+ chunks: "all", // 同步或者异步模块
197
+ maxAsyncRequests: 10, // 最大异步加载并行请求数
198
+ maxInitialRequests: 10, // 入口点最大加载并行请求数
199
+ cacheGroups: {
200
+ // Vue生态依赖变化频率低,单独拆包提升长期缓存命中率
201
+ vueVendor: {
202
+ test: /[\\/]node_modules[\\/](vue|@vue|vue-router|pinia)[\\/]/,
203
+ name: "vue-vendor",
204
+ chunks: "initial",
205
+ priority: 30,
206
+ },
207
+ // 缓存组,将第三方库单独打包
208
+ vendor: {
209
+ test: /[\\/]node_modules[\\/]/, // 匹配node_modules中的模块
210
+ name: "vendor", // chunk名称
211
+ chunks: "initial", // 只抽离首屏同步依赖,动态import依赖保留在异步chunk中
212
+ priority: 20, // 优先级
213
+ },
214
+ // 缓存组,将超过2个地方引用的单独打包
215
+ common: {
216
+ name: "common",
217
+ chunks: "initial",
218
+ priority: 10,
219
+ minChunks: 2, // 最小引用次数
220
+ minSize: 1024, // 最小大小
221
+ reuseExistingChunk: true,
222
+ },
223
+ },
224
+ },
225
+ },
226
+ plugins: [
227
+ /**
228
+ * 处理.vue文件,这个插件是必须的
229
+ * 将定义过的解析规则应用到vue文件中
230
+ */
231
+ new VueLoaderPlugin(),
232
+ // 把第三方库暴露在window 上下文中
233
+ new webpack.ProvidePlugin({
234
+ Vue: "vue",
235
+ }),
236
+ // 定义全局常量
237
+ new webpack.DefinePlugin({
238
+ // 默认兼容vue3语法,纯vue2语法可以选择不开这个全局控制变量,减小包体积
239
+ __VUE_OPTIONS_API__: "true",
240
+ // 是否开启 Devtools 调试
241
+ __VUE_PROD_DEVTOOLS__: "false",
242
+ // SSR 场景下,是否输出水合不匹配详细日志
243
+ __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: "false",
244
+ "process.env.APP_ENV": JSON.stringify(process.env.NODE_ENV),
245
+ }),
246
+ Components({
247
+ resolvers: [
248
+ AntDesignVueResolver({
249
+ importStyle: false, // css由mini-css单独抽离,不内联
250
+ resolveIcons: true, // 图标也按需引入
251
+ }),
252
+ ],
253
+ }),
254
+ // 创建页面文件,自动注入chunk
255
+ ...htmlWebpackPluginList,
256
+ // new BundleAnalyzerPlugin(),
257
+ new CopyPlugin({
258
+ patterns: [
259
+ {
260
+ from: path.join(__dirname, `..${sep}..${sep}public${sep}static`),
261
+ to: path.join(process.cwd(), `app${sep}public${sep}dist${sep}static`),
262
+ },
263
+ ],
264
+ }),
265
+ ],
266
+ };
267
+
268
+ const merge = mergeWithRules({
269
+ module: {
270
+ rules: {
271
+ test: "match",
272
+ use: "replace",
273
+ },
274
+ },
275
+ });
276
+
277
+ // 加载业务webapck配置
278
+ let businessWebpackConfig = {};
279
+ try {
280
+ const config = require(path.join(process.cwd(), `app${sep}webpack.config.js`));
281
+ if (config && typeof config === "object") {
282
+ businessWebpackConfig = config;
283
+ }
284
+ } catch {
285
+ console.log("未找到业务webpack配置文件,使用默认配置");
286
+ }
287
+
288
+ module.exports = merge(webpackBaseConfig, businessWebpackConfig);