@xujingquan/elpis 1.0.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/.browserslistrc +3 -0
- package/.eslintignore +4 -0
- package/.eslintrc +63 -0
- package/.husky/commit-msg +1 -0
- package/.husky/pre-commit +1 -0
- package/.prettierignore +16 -0
- package/.prettierrc +10 -0
- package/README.md +248 -0
- package/app/controller/base.js +41 -0
- package/app/controller/project.js +75 -0
- package/app/controller/view.js +28 -0
- package/app/extend/logger.js +39 -0
- package/app/middleware/api-params-verify.js +90 -0
- package/app/middleware/api-sign-veriyf.js +47 -0
- package/app/middleware/error-handler.js +33 -0
- package/app/middleware/project-handler.js +30 -0
- package/app/middleware.js +45 -0
- package/app/pages/asserts/custom.css +13 -0
- package/app/pages/boot.js +56 -0
- package/app/pages/common/api/business-api.js +19 -0
- package/app/pages/common/api/project-api.js +27 -0
- package/app/pages/common/request.js +119 -0
- package/app/pages/common/utils.js +2 -0
- package/app/pages/dashboard/complex-view/header-view/complex-view/sub-menu/sub-menu.vue +20 -0
- package/app/pages/dashboard/complex-view/header-view/header-view.vue +116 -0
- package/app/pages/dashboard/complex-view/iframe-view/iframe-view.vue +44 -0
- package/app/pages/dashboard/complex-view/schema-view/complex-view/search-panel/search-panel.vue +37 -0
- package/app/pages/dashboard/complex-view/schema-view/complex-view/table-panel/table-panel.vue +122 -0
- package/app/pages/dashboard/complex-view/schema-view/components/component-config.js +23 -0
- package/app/pages/dashboard/complex-view/schema-view/components/create-form/create-form.vue +86 -0
- package/app/pages/dashboard/complex-view/schema-view/components/detail-panel/detail-panel.vue +82 -0
- package/app/pages/dashboard/complex-view/schema-view/components/edit-form/edit-form.vue +115 -0
- package/app/pages/dashboard/complex-view/schema-view/hook/schema.js +135 -0
- package/app/pages/dashboard/complex-view/schema-view/schema-view.vue +93 -0
- package/app/pages/dashboard/complex-view/sider-view/complex-view/sub-menu/sub-menu.vue +21 -0
- package/app/pages/dashboard/complex-view/sider-view/sider-view.vue +115 -0
- package/app/pages/dashboard/dashboard.vue +93 -0
- package/app/pages/dashboard/entry.dashboard.js +45 -0
- package/app/pages/store/index.js +4 -0
- package/app/pages/store/menu.js +61 -0
- package/app/pages/store/project.js +17 -0
- package/app/pages/widgets/header-container/asserts/avatar.png +0 -0
- package/app/pages/widgets/header-container/asserts/logo.png +0 -0
- package/app/pages/widgets/header-container/header-container.vue +111 -0
- package/app/pages/widgets/schema-form/complex-view/input/input.vue +141 -0
- package/app/pages/widgets/schema-form/complex-view/input-number/input-number.vue +142 -0
- package/app/pages/widgets/schema-form/complex-view/select/select.vue +119 -0
- package/app/pages/widgets/schema-form/form-item-config.js +23 -0
- package/app/pages/widgets/schema-form/schema-form.vue +130 -0
- package/app/pages/widgets/schema-search-bar/complex-view/date-range/date-range.vue +50 -0
- package/app/pages/widgets/schema-search-bar/complex-view/dynamic-select/dynamic-select.vue +62 -0
- package/app/pages/widgets/schema-search-bar/complex-view/input/input.vue +40 -0
- package/app/pages/widgets/schema-search-bar/complex-view/select/select.vue +48 -0
- package/app/pages/widgets/schema-search-bar/schema-search-bar.vue +121 -0
- package/app/pages/widgets/schema-search-bar/search-item-config.js +27 -0
- package/app/pages/widgets/schema-table/schema-table.vue +243 -0
- package/app/pages/widgets/sider-container/sider-container.vue +26 -0
- package/app/public/static/logo.png +0 -0
- package/app/public/static/md5.js +950 -0
- package/app/public/static/normalize.css +267 -0
- package/app/router/project.js +11 -0
- package/app/router/view.js +13 -0
- package/app/router-schema/project.js +33 -0
- package/app/service/base.js +14 -0
- package/app/service/project.js +43 -0
- package/app/view/entry.tpl +27 -0
- package/app/webpack/config/utils.js +49 -0
- package/app/webpack/config/webpack-dev.js +55 -0
- package/app/webpack/config/webpack-prod.js +192 -0
- package/app/webpack/config/webpack.base.js +273 -0
- package/app/webpack/dev.js +60 -0
- package/app/webpack/libs/blank.js +1 -0
- package/app/webpack/prod.js +27 -0
- package/babel.config.js +15 -0
- package/commitlint.config.js +3 -0
- package/config/config.default.js +4 -0
- package/elpis-core/env.js +20 -0
- package/elpis-core/index.js +86 -0
- package/elpis-core/loader/config.js +54 -0
- package/elpis-core/loader/controller.js +69 -0
- package/elpis-core/loader/extend.js +57 -0
- package/elpis-core/loader/middleware.js +66 -0
- package/elpis-core/loader/router-schema.js +49 -0
- package/elpis-core/loader/router.js +50 -0
- package/elpis-core/loader/service.js +69 -0
- package/index.js +47 -0
- package/jsconfig.json +19 -0
- package/model/index.js +103 -0
- package/package.json +105 -0
- package/test/controller/project.test.js +200 -0
|
@@ -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
|
+
margin: 0;
|
|
41
|
+
padding: 0;
|
|
42
|
+
list-style: none;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
html {
|
|
46
|
+
font-family: 'Open Sans', 'Helvetica Neue', 'Microsoft Yahei', sans-serif;
|
|
47
|
+
-ms-text-size-adjust: 100%; /* 2 */
|
|
48
|
+
-webkit-text-size-adjust: 100%; /* 2 */ /* 1 */
|
|
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
|
+
text-decoration: none;
|
|
68
|
+
background-color: transparent;
|
|
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
|
+
margin: 0; /* 3 */
|
|
135
|
+
color: inherit; /* 1 */
|
|
136
|
+
font: inherit; /* 2 */
|
|
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
|
+
cursor: pointer; /* 3 */
|
|
172
|
+
-webkit-appearance: button; /* 2 */
|
|
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
|
+
padding: 0;
|
|
191
|
+
border: 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
|
+
-moz-box-sizing: content-box;
|
|
236
|
+
-webkit-box-sizing: content-box; /* 2 */
|
|
237
|
+
box-sizing: content-box;
|
|
238
|
+
-webkit-appearance: textfield; /* 1 */
|
|
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,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 路由
|
|
3
|
+
* */
|
|
4
|
+
|
|
5
|
+
module.exports = (app, router) => {
|
|
6
|
+
// controller loader 挂载在 app 上的对象
|
|
7
|
+
const { project: projectController } = app.controller;
|
|
8
|
+
router.get('/api/project', projectController.get.bind(projectController));
|
|
9
|
+
router.get('/api/project/list', projectController.getList.bind(projectController));
|
|
10
|
+
router.get('/api/project/model_list', projectController.getModelList.bind(projectController));
|
|
11
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 路由
|
|
3
|
+
* */
|
|
4
|
+
|
|
5
|
+
module.exports = (app, router) => {
|
|
6
|
+
// controller loader 挂载在 app 上的对象
|
|
7
|
+
const { view: viewController } = app.controller;
|
|
8
|
+
|
|
9
|
+
// 用户输入 https://ip:port/view/xxxx 就能渲染出对应的页面
|
|
10
|
+
router.get('/view/:page', viewController.renderPage.bind(viewController));
|
|
11
|
+
// 用户输入 https://ip:port/view/xxxx/xxxx/* 就能渲染出对应的页面
|
|
12
|
+
router.get('/view/:page/*', viewController.renderPage.bind(viewController));
|
|
13
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 接口校验
|
|
3
|
+
*/
|
|
4
|
+
module.exports = {
|
|
5
|
+
'/api/project': {
|
|
6
|
+
get: {
|
|
7
|
+
query: {
|
|
8
|
+
type: 'object',
|
|
9
|
+
properties: {
|
|
10
|
+
proj_key: {
|
|
11
|
+
type: 'string',
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
required: ['proj_key'],
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
'/api/project/list': {
|
|
19
|
+
get: {
|
|
20
|
+
query: {
|
|
21
|
+
type: 'object',
|
|
22
|
+
properties: {
|
|
23
|
+
proj_key: {
|
|
24
|
+
type: 'string',
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
'/api/project/model_list': {
|
|
31
|
+
get: {},
|
|
32
|
+
},
|
|
33
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const superagent = require('superagent');
|
|
2
|
+
module.exports = app => {
|
|
3
|
+
return class BaseService {
|
|
4
|
+
/**
|
|
5
|
+
* service 基类
|
|
6
|
+
* 统一收拢 service 层的公共方法
|
|
7
|
+
*/
|
|
8
|
+
constructor() {
|
|
9
|
+
this.app = app;
|
|
10
|
+
this.config = app.config;
|
|
11
|
+
this.curl = superagent;
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
module.exports = (app) => {
|
|
2
|
+
const BaseService = require('./base')(app);
|
|
3
|
+
const modelList = require('../../model/index')(app);
|
|
4
|
+
return class ProjectService extends BaseService {
|
|
5
|
+
/**
|
|
6
|
+
* 根据 projKey 获取项目配置
|
|
7
|
+
* */
|
|
8
|
+
get(projKey) {
|
|
9
|
+
let projConfig;
|
|
10
|
+
|
|
11
|
+
modelList.forEach((modelItem) => {
|
|
12
|
+
if (modelItem.project[projKey]) {
|
|
13
|
+
projConfig = modelItem.project[projKey];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
return projConfig;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* 获取统一模型下的项目列表(如果无 projKey 取全量)
|
|
21
|
+
*/
|
|
22
|
+
getList({ projKey }) {
|
|
23
|
+
return modelList.reduce((preList, modelItem) => {
|
|
24
|
+
const { project } = modelItem;
|
|
25
|
+
|
|
26
|
+
// 如果有传 projKey 则只去当前相同模型下的项目,不传的情况下取全量
|
|
27
|
+
if (projKey && !project[projKey]) return preList;
|
|
28
|
+
|
|
29
|
+
for (const pKey in project) {
|
|
30
|
+
preList.push(project[pKey]);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return preList;
|
|
34
|
+
}, []);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* 获取所有模型与项目的结构化数据
|
|
38
|
+
*/
|
|
39
|
+
getModelList() {
|
|
40
|
+
return modelList;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html class="dark">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0" />
|
|
6
|
+
<title>{{ name }}</title>
|
|
7
|
+
<!-- 需要使用 koa-static 配置资源目录 -->
|
|
8
|
+
<link rel="stylesheet" href="/static/normalize.css" />
|
|
9
|
+
<link rel="icon" href="/static/logo.png" type="image/x-icon" />
|
|
10
|
+
</head>
|
|
11
|
+
<body style="color: aquamarine">
|
|
12
|
+
<div id="root"></div>
|
|
13
|
+
<input id="projKey" value="{{ projKey }}" style="display: none" />
|
|
14
|
+
<input type="text" id="env" value="{{ env }}" style="display: none" />
|
|
15
|
+
<input type="text" id="options" value="{{ options }}" style="display: none" />
|
|
16
|
+
</body>
|
|
17
|
+
<script>
|
|
18
|
+
try {
|
|
19
|
+
window.projKey = document.getElementById('projKey').value;
|
|
20
|
+
window.env = document.getElementById('env').value;
|
|
21
|
+
const options = document.getElementById('options').value;
|
|
22
|
+
window.options = JSON.parse(options);
|
|
23
|
+
} catch (e) {
|
|
24
|
+
console.log(e);
|
|
25
|
+
}
|
|
26
|
+
</script>
|
|
27
|
+
</html>
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
function cssCollectSafelist() {
|
|
2
|
+
return {
|
|
3
|
+
standard: [
|
|
4
|
+
'html',
|
|
5
|
+
'body',
|
|
6
|
+
'span',
|
|
7
|
+
'div',
|
|
8
|
+
'p',
|
|
9
|
+
'a',
|
|
10
|
+
'table',
|
|
11
|
+
'tbody',
|
|
12
|
+
'td',
|
|
13
|
+
'h1',
|
|
14
|
+
'h2',
|
|
15
|
+
'h3',
|
|
16
|
+
'img',
|
|
17
|
+
'form',
|
|
18
|
+
'font',
|
|
19
|
+
'strong',
|
|
20
|
+
'b',
|
|
21
|
+
'i',
|
|
22
|
+
'dl',
|
|
23
|
+
'dt',
|
|
24
|
+
'dd',
|
|
25
|
+
'ol',
|
|
26
|
+
'ul',
|
|
27
|
+
'li',
|
|
28
|
+
'dl',
|
|
29
|
+
'dd',
|
|
30
|
+
'dt',
|
|
31
|
+
'iframe',
|
|
32
|
+
'label',
|
|
33
|
+
'blockquote',
|
|
34
|
+
'input',
|
|
35
|
+
'button',
|
|
36
|
+
'figure',
|
|
37
|
+
'dark',
|
|
38
|
+
],
|
|
39
|
+
// 针对 element-plus 的通用 safelist
|
|
40
|
+
// 1)所有以 el- 开头的类名,例如 el-button、el-input 等
|
|
41
|
+
// 2)所有以 is- 开头的状态类,例如 is-active、is-disabled 等
|
|
42
|
+
// 3)所有以 el-icon- 开头的图标类
|
|
43
|
+
deep: [/^el-/, /^is-/, /^el-icon-/],
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
module.exports = {
|
|
48
|
+
cssCollectSafelist,
|
|
49
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
const merge = require('webpack-merge');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const webpack = require('webpack');
|
|
4
|
+
|
|
5
|
+
// 基础配置
|
|
6
|
+
const baseConfig = require('./webpack.base');
|
|
7
|
+
|
|
8
|
+
// devServer 配置
|
|
9
|
+
const DEV_SERVER_CONFIG = {
|
|
10
|
+
HOST: '127.0.0.1',
|
|
11
|
+
PORT: 9002,
|
|
12
|
+
HMR_PATH: '__webpack_hmr', // 官方规定
|
|
13
|
+
TIMEOUT: 20000,
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
// 开发阶段的 entry 配置需要加入 hmr
|
|
17
|
+
Object.keys(baseConfig.entry).forEach((v) => {
|
|
18
|
+
// 第三方包不作为 hmr 入口
|
|
19
|
+
if (v !== 'vendor') {
|
|
20
|
+
baseConfig.entry[v] = [
|
|
21
|
+
// 主入口文件
|
|
22
|
+
baseConfig.entry[v],
|
|
23
|
+
// hmr 更新入口,官方指定的 hmr 路径
|
|
24
|
+
`${require.resolve('webpack-hot-middleware/client')}?path=http://${DEV_SERVER_CONFIG.HOST}:${
|
|
25
|
+
DEV_SERVER_CONFIG.PORT
|
|
26
|
+
}/${DEV_SERVER_CONFIG.HMR_PATH}&timeout=${DEV_SERVER_CONFIG.TIMEOUT}&reload=true`,
|
|
27
|
+
];
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const webpackConfig = merge(baseConfig, {
|
|
32
|
+
mode: 'development',
|
|
33
|
+
devtool: 'cheap-module-source-map',
|
|
34
|
+
output: {
|
|
35
|
+
filename: 'js/[name]_[chunkhash:8].bundle.js',
|
|
36
|
+
path: path.resolve(process.cwd(), './app/public/dist/dev/'), // 输出文件存储路径
|
|
37
|
+
publicPath: `http://${DEV_SERVER_CONFIG.HOST}:${DEV_SERVER_CONFIG.PORT}/public/dist/dev/`, // 外部资源路径
|
|
38
|
+
globalObject: 'self',
|
|
39
|
+
},
|
|
40
|
+
plugins: [
|
|
41
|
+
// HotModuleReplacementPlugin 用于实现热模块替换(HMR)
|
|
42
|
+
// 模块热更新允许在应用程序运行时替换模块
|
|
43
|
+
// 极大的提升开发效率,因为能让应用程序一直保持运行状态
|
|
44
|
+
new webpack.HotModuleReplacementPlugin({
|
|
45
|
+
multiStep: false,
|
|
46
|
+
}),
|
|
47
|
+
],
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
module.exports = {
|
|
51
|
+
// webpack 配置
|
|
52
|
+
webpackConfig,
|
|
53
|
+
// devServer 配置,暴露给 dev.js
|
|
54
|
+
DEV_SERVER_CONFIG,
|
|
55
|
+
};
|