@lixianwei/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/.eslintignore +2 -0
- package/.eslintrc +55 -0
- package/.idea/dictionaries/project.xml +8 -0
- package/.idea/elpis.iml +8 -0
- package/.idea/git_toolbox_prj.xml +15 -0
- package/.idea/inspectionProfiles/Project_Default.xml +329 -0
- package/.idea/modules.xml +8 -0
- package/.idea/vcs.xml +6 -0
- package/README.md +201 -0
- package/app/controller/base.js +77 -0
- package/app/controller/project.js +69 -0
- package/app/controller/view.js +20 -0
- package/app/extend/logger.js +35 -0
- package/app/middleware/api-params-verify.js +74 -0
- package/app/middleware/api-sign-verify.js +33 -0
- package/app/middleware/error-hander.js +32 -0
- package/app/middleware/project-handler.js +25 -0
- package/app/middleware.js +37 -0
- package/app/pages/asserts/custom.css +11 -0
- package/app/pages/boot.js +43 -0
- package/app/pages/common/curl.js +83 -0
- package/app/pages/common/index.js +2 -0
- package/app/pages/common/utils.js +0 -0
- package/app/pages/dashboard/complex-view/header-view/complex-view/sub-menu/sub-menu.vue +23 -0
- package/app/pages/dashboard/complex-view/header-view/header-view.vue +117 -0
- package/app/pages/dashboard/complex-view/iframe-view/iframe-view.vue +40 -0
- package/app/pages/dashboard/complex-view/schema-view/complex-view/search-panel/search-panel.vue +45 -0
- package/app/pages/dashboard/complex-view/schema-view/complex-view/tabel-panel/tabel-panel.vue +134 -0
- package/app/pages/dashboard/complex-view/schema-view/components/component-config.js +20 -0
- package/app/pages/dashboard/complex-view/schema-view/components/create-form/create-form.vue +89 -0
- package/app/pages/dashboard/complex-view/schema-view/components/detail-panel/detail-panel.vue +101 -0
- package/app/pages/dashboard/complex-view/schema-view/components/edit-form/edit-form.vue +128 -0
- package/app/pages/dashboard/complex-view/schema-view/hook/schema.js +119 -0
- package/app/pages/dashboard/complex-view/schema-view/schema-view.vue +96 -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 +117 -0
- package/app/pages/dashboard/dashboard.vue +88 -0
- package/app/pages/dashboard/entry.dashboard.js +41 -0
- package/app/pages/router/index.js +11 -0
- package/app/pages/store/index.js +4 -0
- package/app/pages/store/menu.js +65 -0
- package/app/pages/store/project.js +16 -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 +103 -0
- package/app/pages/widgets/schema-form/complex-view/input/input.vue +142 -0
- package/app/pages/widgets/schema-form/complex-view/input-number/input-number.vue +143 -0
- package/app/pages/widgets/schema-form/complex-view/select/select.vue +130 -0
- package/app/pages/widgets/schema-form/form-item-config.js +20 -0
- package/app/pages/widgets/schema-form/schema-form.vue +132 -0
- package/app/pages/widgets/schema-search-bar/complex-view/date-range/date-range.vue +48 -0
- package/app/pages/widgets/schema-search-bar/complex-view/dynamic-select/dynamic-select.vue +67 -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 +50 -0
- package/app/pages/widgets/schema-search-bar/schema-search-bar.vue +142 -0
- package/app/pages/widgets/schema-search-bar/search-item-config.js +24 -0
- package/app/pages/widgets/schema-table/schema-table.vue +238 -0
- package/app/pages/widgets/sider-container/sider-container.vue +31 -0
- package/app/public/static/logo.png +0 -0
- package/app/public/static/normalize.css +239 -0
- package/app/router/project.js +9 -0
- package/app/router/view.js +7 -0
- package/app/router-schema/project.js +32 -0
- package/app/service/base.js +12 -0
- package/app/service/project.js +42 -0
- package/app/view/entry.tpl +26 -0
- package/app/webpack/config/webpack.base.js +219 -0
- package/app/webpack/config/webpack.dev.js +55 -0
- package/app/webpack/config/webpack.prod.js +118 -0
- package/app/webpack/dev.js +52 -0
- package/app/webpack/libs/blank.js +2 -0
- package/app/webpack/prod.js +18 -0
- package/config/config.default.js +3 -0
- package/elpis-core/env.js +20 -0
- package/elpis-core/index.js +92 -0
- package/elpis-core/loader/config.js +54 -0
- package/elpis-core/loader/controller.js +61 -0
- package/elpis-core/loader/extend.js +55 -0
- package/elpis-core/loader/middleware.js +61 -0
- package/elpis-core/loader/router-schema.js +39 -0
- package/elpis-core/loader/router.js +42 -0
- package/elpis-core/loader/service.js +64 -0
- package/index.js +41 -0
- package/model/index.js +105 -0
- package/package.json +94 -0
- package/test/controller/project.test.js +194 -0
|
@@ -0,0 +1,239 @@
|
|
|
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,body,span,div,p,a,table,tbody,td,h1,h2,h3,img,form,font,strong,b,i,dl,dt,dd,ol,ul,li,dl,dd,dt,iframe,label,blockquote,input,button
|
|
9
|
+
{
|
|
10
|
+
padding: 0;
|
|
11
|
+
margin: 0;
|
|
12
|
+
list-style: none;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
html {
|
|
16
|
+
font-family: "Open Sans","Helvetica Neue","Microsoft Yahei",sans-serif;/* 1 */
|
|
17
|
+
-ms-text-size-adjust: 100%; /* 2 */
|
|
18
|
+
-webkit-text-size-adjust: 100%; /* 2 */
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Remove default margin.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
body {
|
|
26
|
+
margin: 0;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/* Links
|
|
30
|
+
========================================================================== */
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Remove the gray background color from active links in IE 10.
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
a {
|
|
37
|
+
background-color: transparent;
|
|
38
|
+
text-decoration: none;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Improve readability when focused and also mouse hovered in all browsers.
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
a:active,
|
|
46
|
+
a:hover {
|
|
47
|
+
outline: 0;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/* Text-level semantics
|
|
51
|
+
========================================================================== */
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Address style set to `bolder` in Firefox 4+, Safari, and Chrome.
|
|
55
|
+
*/
|
|
56
|
+
|
|
57
|
+
b,
|
|
58
|
+
strong {
|
|
59
|
+
font-weight: bold;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/* Embedded content
|
|
63
|
+
========================================================================== */
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Remove border when inside `a` element in IE 8/9/10.
|
|
67
|
+
*/
|
|
68
|
+
|
|
69
|
+
img {
|
|
70
|
+
border: 0;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
/* Grouping content
|
|
75
|
+
========================================================================== */
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Address margin not present in IE 8/9 and Safari.
|
|
79
|
+
*/
|
|
80
|
+
|
|
81
|
+
figure {
|
|
82
|
+
margin: 1em 40px;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
/* Forms
|
|
87
|
+
========================================================================== */
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Known limitation: by default, Chrome and Safari on OS X allow very limited
|
|
91
|
+
* styling of `select`, unless a `border` property is set.
|
|
92
|
+
*/
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* 1. Correct color not being inherited.
|
|
96
|
+
* Known issue: affects color of disabled elements.
|
|
97
|
+
* 2. Correct font properties not being inherited.
|
|
98
|
+
* 3. Address margins set differently in Firefox 4+, Safari, and Chrome.
|
|
99
|
+
*/
|
|
100
|
+
|
|
101
|
+
button,
|
|
102
|
+
input,
|
|
103
|
+
optgroup,
|
|
104
|
+
select,
|
|
105
|
+
textarea {
|
|
106
|
+
color: inherit; /* 1 */
|
|
107
|
+
font: inherit; /* 2 */
|
|
108
|
+
margin: 0; /* 3 */
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Address `overflow` set to `hidden` in IE 8/9/10/11.
|
|
113
|
+
*/
|
|
114
|
+
|
|
115
|
+
button {
|
|
116
|
+
overflow: visible;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Address inconsistent `text-transform` inheritance for `button` and `select`.
|
|
121
|
+
* All other form control elements do not inherit `text-transform` values.
|
|
122
|
+
* Correct `button` style inheritance in Firefox, IE 8/9/10/11, and Opera.
|
|
123
|
+
* Correct `select` style inheritance in Firefox.
|
|
124
|
+
*/
|
|
125
|
+
|
|
126
|
+
button,
|
|
127
|
+
select {
|
|
128
|
+
text-transform: none;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio`
|
|
133
|
+
* and `video` controls.
|
|
134
|
+
* 2. Correct inability to style clickable `input` types in iOS.
|
|
135
|
+
* 3. Improve usability and consistency of cursor style between image-type
|
|
136
|
+
* `input` and others.
|
|
137
|
+
*/
|
|
138
|
+
|
|
139
|
+
button,
|
|
140
|
+
html input[type="button"], /* 1 */
|
|
141
|
+
input[type="reset"],
|
|
142
|
+
input[type="submit"] {
|
|
143
|
+
-webkit-appearance: button; /* 2 */
|
|
144
|
+
cursor: pointer; /* 3 */
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Re-set default cursor for disabled elements.
|
|
149
|
+
*/
|
|
150
|
+
|
|
151
|
+
button[disabled],
|
|
152
|
+
html input[disabled] {
|
|
153
|
+
cursor: default;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Remove inner padding and border in Firefox 4+.
|
|
158
|
+
*/
|
|
159
|
+
|
|
160
|
+
button::-moz-focus-inner,
|
|
161
|
+
input::-moz-focus-inner {
|
|
162
|
+
border: 0;
|
|
163
|
+
padding: 0;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Address Firefox 4+ setting `line-height` on `input` using `!important` in
|
|
168
|
+
* the UA stylesheet.
|
|
169
|
+
*/
|
|
170
|
+
|
|
171
|
+
input {
|
|
172
|
+
line-height: normal;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* It's recommended that you don't attempt to style these elements.
|
|
177
|
+
* Firefox's implementation doesn't respect box-sizing, padding, or width.
|
|
178
|
+
*
|
|
179
|
+
* 1. Address box sizing set to `content-box` in IE 8/9/10.
|
|
180
|
+
* 2. Remove excess padding in IE 8/9/10.
|
|
181
|
+
*/
|
|
182
|
+
|
|
183
|
+
input[type="checkbox"],
|
|
184
|
+
input[type="radio"] {
|
|
185
|
+
box-sizing: border-box; /* 1 */
|
|
186
|
+
padding: 0; /* 2 */
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Fix the cursor style for Chrome's increment/decrement buttons. For certain
|
|
191
|
+
* `font-size` values of the `input`, it causes the cursor style of the
|
|
192
|
+
* decrement button to change from `default` to `text`.
|
|
193
|
+
*/
|
|
194
|
+
|
|
195
|
+
input[type="number"]::-webkit-inner-spin-button,
|
|
196
|
+
input[type="number"]::-webkit-outer-spin-button {
|
|
197
|
+
height: auto;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* 1. Address `appearance` set to `searchfield` in Safari and Chrome.
|
|
202
|
+
* 2. Address `box-sizing` set to `border-box` in Safari and Chrome
|
|
203
|
+
* (include `-moz` to future-proof).
|
|
204
|
+
*/
|
|
205
|
+
|
|
206
|
+
input[type="search"] {
|
|
207
|
+
-webkit-appearance: textfield; /* 1 */
|
|
208
|
+
-moz-box-sizing: content-box;
|
|
209
|
+
-webkit-box-sizing: content-box; /* 2 */
|
|
210
|
+
box-sizing: content-box;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Remove inner padding and search cancel button in Safari and Chrome on OS X.
|
|
215
|
+
* Safari (but not Chrome) clips the cancel button when the search input has
|
|
216
|
+
* padding (and `textfield` appearance).
|
|
217
|
+
*/
|
|
218
|
+
|
|
219
|
+
input[type="search"]::-webkit-search-cancel-button,
|
|
220
|
+
input[type="search"]::-webkit-search-decoration {
|
|
221
|
+
-webkit-appearance: none;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/* Tables
|
|
225
|
+
========================================================================== */
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Remove most spacing between table cells.
|
|
229
|
+
*/
|
|
230
|
+
|
|
231
|
+
table {
|
|
232
|
+
border-collapse: collapse;
|
|
233
|
+
border-spacing: 0;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
td,
|
|
237
|
+
th {
|
|
238
|
+
padding: 0;
|
|
239
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
module.exports = (app,router)=> {
|
|
2
|
+
const {project:ProjectController} = app.controller
|
|
3
|
+
router.get('/api/project',ProjectController.get.bind(ProjectController));
|
|
4
|
+
|
|
5
|
+
router.get('/api/project/list',ProjectController.getList.bind(ProjectController));
|
|
6
|
+
|
|
7
|
+
router.get('/api/project/model_list',ProjectController.getModelList.bind(ProjectController))
|
|
8
|
+
|
|
9
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
module.exports = (app,router)=>{
|
|
2
|
+
const {view:ViewController} = app.controller;
|
|
3
|
+
//用户输入 http://ip:port/view/page1 能渲染出对应的页面
|
|
4
|
+
router.get('/view/:page',ViewController.renderPage.bind(ViewController));
|
|
5
|
+
//用户输入 http://ip:port/view/xxx/xxx/* 能渲染出对应的页面
|
|
6
|
+
router.get('/view/:page/*',ViewController.renderPage.bind(ViewController));
|
|
7
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
module.exports ={
|
|
2
|
+
'/api/project':{
|
|
3
|
+
get:{
|
|
4
|
+
query:{
|
|
5
|
+
type: 'object',
|
|
6
|
+
properties: {
|
|
7
|
+
proj_key:{
|
|
8
|
+
type:'string'
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
required:["proj_key"]
|
|
12
|
+
},
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
'/api/project/list':{
|
|
16
|
+
get:{
|
|
17
|
+
query:{
|
|
18
|
+
type: 'object',
|
|
19
|
+
properties: {
|
|
20
|
+
proj_key:{
|
|
21
|
+
type:'string',
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
'/api/project/model_list':{
|
|
28
|
+
get:{
|
|
29
|
+
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
module.exports =(app)=>{
|
|
2
|
+
const BaseService = require('./base')(app)
|
|
3
|
+
const modelList = require('../../model/index.js')(app)
|
|
4
|
+
return class ProjectService extends BaseService {
|
|
5
|
+
/*
|
|
6
|
+
* 根据proj_key获取项目配置
|
|
7
|
+
* */
|
|
8
|
+
async get(projKey){
|
|
9
|
+
let projConfig;
|
|
10
|
+
modelList.forEach(modelItem => {
|
|
11
|
+
if(modelItem.project[projKey]) {
|
|
12
|
+
projConfig = modelItem.project[projKey]
|
|
13
|
+
}
|
|
14
|
+
})
|
|
15
|
+
return projConfig
|
|
16
|
+
}
|
|
17
|
+
/*
|
|
18
|
+
* 获取当前 projectKey 对应模型下的项目列表 (如果无projectKey,全量获取)
|
|
19
|
+
* */
|
|
20
|
+
async getList({projKey}){
|
|
21
|
+
return modelList.reduce((projList,modelItem)=>{
|
|
22
|
+
const {project} = modelItem;
|
|
23
|
+
// 如果传projKey 则只取当前同模型下的数据,如果不传的情况下就差全量
|
|
24
|
+
if(projKey && !project[projKey]){
|
|
25
|
+
return projList
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
for(const projKey in project){
|
|
29
|
+
projList.push(project[projKey])
|
|
30
|
+
}
|
|
31
|
+
return projList
|
|
32
|
+
},[])
|
|
33
|
+
|
|
34
|
+
}
|
|
35
|
+
/*
|
|
36
|
+
* 获取所有模型项目的数据结构
|
|
37
|
+
* */
|
|
38
|
+
async getModelList(){
|
|
39
|
+
return modelList
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html class="dark">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<link href="/static/normalize.css" rel="stylesheet">
|
|
6
|
+
<link href="/static/logo.png" rel="icon" type="image/x-icon">
|
|
7
|
+
<title>{{name}}</title>
|
|
8
|
+
</head>
|
|
9
|
+
<body style="margin:0">
|
|
10
|
+
<div id="root"></div>
|
|
11
|
+
<input id="projKey" value="{{projKey}}" style="display:none"/>
|
|
12
|
+
<input id="env" value="{{env}}" style="display:none"/>
|
|
13
|
+
<input id="options" value="{{options}}" style="display:none"/>
|
|
14
|
+
</body>
|
|
15
|
+
<script type="text/javascript">
|
|
16
|
+
try{
|
|
17
|
+
window.projKey = document.getElementById('projKey').value;
|
|
18
|
+
window.env = document.getElementById('env').value;
|
|
19
|
+
const options = document.getElementById('options').value
|
|
20
|
+
window.options = JSON.parse(options)
|
|
21
|
+
} catch(e){
|
|
22
|
+
console.log(e)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
</script>
|
|
26
|
+
</html>
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
const glob = require('glob');
|
|
2
|
+
const path = require('path')
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const webpack = require('webpack')
|
|
5
|
+
const merge = require('webpack-merge');
|
|
6
|
+
const {VueLoaderPlugin} = require('vue-loader');
|
|
7
|
+
const HtmlWebpackPlugin = require("html-webpack-plugin");
|
|
8
|
+
|
|
9
|
+
// 动态构造 elpisPageEntries elpisHtmlWebpackPluginList
|
|
10
|
+
const elpisPageEntries={}
|
|
11
|
+
const elpisHtmlWebpackPluginList =[]
|
|
12
|
+
// 获取elpis/app文件中pages目录下的所有带有entry.*.js的相关文件
|
|
13
|
+
const elpisEntriesList = path.resolve(__dirname, '../../pages/**/entry.*.js');
|
|
14
|
+
// 将获取到的文件通过glob.sync 转换成数组,并且进行文件遍历
|
|
15
|
+
glob.sync(elpisEntriesList).forEach(file => {
|
|
16
|
+
handleFile(file,elpisPageEntries,elpisHtmlWebpackPluginList)
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
// 动态构造 businessPageEntries businessHtmlWebpackPluginList
|
|
20
|
+
const businessPageEntries={}
|
|
21
|
+
const businessHtmlWebpackPluginList =[]
|
|
22
|
+
// 获取业务/app文件中pages目录下的所有带有entry.*.js的相关文件
|
|
23
|
+
const businessEntriesList = path.resolve(process.cwd(), './app/pages/**/entry.*.js');
|
|
24
|
+
// 将获取到的文件通过glob.sync 转换成数组,并且进行文件遍历
|
|
25
|
+
glob.sync(businessEntriesList).forEach(file => {
|
|
26
|
+
handleFile(file,businessPageEntries,businessHtmlWebpackPluginList)
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
// 构造相关webpack处理的数据结构
|
|
30
|
+
function handleFile(file,entries ={},htmlWebPackPluginList = []){
|
|
31
|
+
// 获取到js文件的名称 entry.*
|
|
32
|
+
const entryname = path.basename(file, '.js');
|
|
33
|
+
// 构造entry
|
|
34
|
+
entries[entryname] = file;
|
|
35
|
+
// 构造最终渲染的页面文件
|
|
36
|
+
htmlWebPackPluginList.push(
|
|
37
|
+
// htmlWebpackPlugin 辅助注入打包后的bundle 文件到tpl文件中
|
|
38
|
+
new HtmlWebpackPlugin({
|
|
39
|
+
// 产物最终模板 输出路径
|
|
40
|
+
filename:path.resolve(process.cwd(),'./app/public/dist/',`${entryname}.tpl`),
|
|
41
|
+
// 指定要使用的模板文件
|
|
42
|
+
template:path.resolve(__dirname,'../../view/entry.tpl'),
|
|
43
|
+
// 要注入的代码块
|
|
44
|
+
chunks: [entryname]
|
|
45
|
+
})
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
// 加载业务webpack 配置
|
|
51
|
+
let buinessWebPackConfig ={};
|
|
52
|
+
|
|
53
|
+
try{
|
|
54
|
+
buinessWebPackConfig = require(`${process.cwd()}/app/webpack.config.js`)
|
|
55
|
+
} catch (e) {
|
|
56
|
+
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/*
|
|
60
|
+
* webpack 配置
|
|
61
|
+
* */
|
|
62
|
+
module.exports= merge.smart({
|
|
63
|
+
// 入口配置
|
|
64
|
+
entry:Object.assign({},elpisPageEntries,businessPageEntries),
|
|
65
|
+
// 模块解析配置(决定了要加载解析哪些模块,以及用什么方式去解析)
|
|
66
|
+
module:{
|
|
67
|
+
rules:[
|
|
68
|
+
{
|
|
69
|
+
test: /\.vue$/,
|
|
70
|
+
use: {
|
|
71
|
+
loader:require.resolve('vue-loader')
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
test: /\.js$/,
|
|
76
|
+
include: [
|
|
77
|
+
// 处理elpis 目录
|
|
78
|
+
path.resolve(__dirname, '../../pages'),
|
|
79
|
+
// 处理业务目录
|
|
80
|
+
path.resolve(process.cwd(), './app/pages'),
|
|
81
|
+
],
|
|
82
|
+
use: {
|
|
83
|
+
loader:require.resolve('babel-loader')
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
test: /\.(png|jpe?g|gif)(\?.+)?$/,
|
|
88
|
+
use: {
|
|
89
|
+
loader:require.resolve('url-loader'),
|
|
90
|
+
options:{
|
|
91
|
+
limit:300,
|
|
92
|
+
esModule:false,
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
test:/\.css$/,
|
|
98
|
+
use:[
|
|
99
|
+
require.resolve('style-loader'),
|
|
100
|
+
require.resolve('css-loader')
|
|
101
|
+
],
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
test:/\.less$/,
|
|
105
|
+
use:[
|
|
106
|
+
require.resolve('style-loader'),
|
|
107
|
+
require.resolve('css-loader'),
|
|
108
|
+
require.resolve('less-loader')
|
|
109
|
+
],
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
test:/\.(eot|ttf|woff|woff2)(\?\S*)?$/,
|
|
113
|
+
use:require.resolve('file-loader'),
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
]
|
|
117
|
+
},
|
|
118
|
+
// 产物输出路径,因为开发和生产环境输出不一致,所以在各自环境中自行配置
|
|
119
|
+
output:{},
|
|
120
|
+
// 配置模块解析的具体行为(定义webpack在打包时,如何找到并解析具体模块路径)
|
|
121
|
+
resolve:{
|
|
122
|
+
extensions: [ '.js','.vue','.less','.css'],
|
|
123
|
+
alias:(()=>{
|
|
124
|
+
const aliasMap ={};
|
|
125
|
+
const blankModulePath = path.resolve(__dirname,'../libs/blank.js');
|
|
126
|
+
// dashborad 路由扩展
|
|
127
|
+
const businessDashboardRouterConfig = path.resolve(process.cwd(),'./app/pages/dashboard/router.js');
|
|
128
|
+
aliasMap['$businessDashboradRouterConfig'] = fs.existsSync(businessDashboardRouterConfig) ? businessDashboardRouterConfig:blankModulePath
|
|
129
|
+
|
|
130
|
+
// schema-view component 扩展配置
|
|
131
|
+
const businessComponentConfig = path.resolve(process.cwd(),'./app/pages/dashboard/complex-view/schema-view/components/component-config.js');
|
|
132
|
+
aliasMap['$businessComponentConfig'] = fs.existsSync(businessComponentConfig) ? businessComponentConfig:blankModulePath
|
|
133
|
+
|
|
134
|
+
// 业务 form-item 配置扩展
|
|
135
|
+
const businessFormItemConfig = path.resolve(process.cwd(),'./app/pages/widgets/schema-form/form-item-config.js');
|
|
136
|
+
aliasMap['$businessFormItemConfig'] = fs.existsSync(businessFormItemConfig) ? businessFormItemConfig:blankModulePath
|
|
137
|
+
|
|
138
|
+
// 业务 search -bar 配置扩展
|
|
139
|
+
const businessSchemaSearchBar = path.resolve(process.cwd(),'./app/pages/widgets/schema-search-bar/search-item-config.js');
|
|
140
|
+
aliasMap['$businessSearchItemConfig'] = fs.existsSync(businessSchemaSearchBar) ? businessSchemaSearchBar:blankModulePath
|
|
141
|
+
return {
|
|
142
|
+
'vue':require.resolve('vue'),
|
|
143
|
+
'@babel/runtime/helpers/asyncToGenerator':require.resolve('@babel/runtime/helpers/asyncToGenerator'),
|
|
144
|
+
'@babel/runtime/regenerator': require.resolve('@babel/runtime/regenerator'),
|
|
145
|
+
'@babel/runtime/helpers/toConsumableArray':require.resolve('@babel/runtime/helpers/toConsumableArray'),
|
|
146
|
+
$elpisPages: path.resolve(__dirname,'../../pages'),
|
|
147
|
+
$elpisCommon: path.resolve(__dirname,'../../pages/common'),
|
|
148
|
+
$elpisCurl:path.resolve(__dirname,'../../pages/common/curl.js'),
|
|
149
|
+
$elpisUtils:path.resolve(__dirname,'../../pages/common/utils.js'),
|
|
150
|
+
$elpisWidgets: path.resolve(__dirname,'../../pages/widgets'),
|
|
151
|
+
$elpisHeaderContainer:path.resolve(__dirname,'../../pages/widgets/header-container/header-container.vue'),
|
|
152
|
+
$elpisSiderContainer:path.resolve(__dirname,'../../pages/widgets/sider-container/sider-container.vue'),
|
|
153
|
+
$elpisSchemaTable:path.resolve(__dirname,'../../pages/widgets/schema-table/schema-table.vue'),
|
|
154
|
+
$elpisSchemaForm:path.resolve(__dirname,'../../pages/widgets/schema-form/schema-form.vue'),
|
|
155
|
+
$elpisSchemaSearchBar:path.resolve(__dirname,'../../pages/widgets/schema-search-bar/schema-search-bar.vue'),
|
|
156
|
+
|
|
157
|
+
$elpisStore: path.resolve(__dirname,'../../pages/store'),
|
|
158
|
+
$elpisBoot: path.resolve(__dirname,'../../pages/boot.js'),
|
|
159
|
+
...aliasMap,
|
|
160
|
+
}
|
|
161
|
+
}) ()
|
|
162
|
+
},
|
|
163
|
+
// 配置webpack插件
|
|
164
|
+
plugins:[
|
|
165
|
+
// 处理.vue文件 这个插件必须的
|
|
166
|
+
// 它的只能是将你定义过的其他规则复制并应用到 .vue文件里
|
|
167
|
+
// 例如 如果有一条匹配规则 /\.js$/ 的规则,那么它会应用到.vue文件中的script板块中
|
|
168
|
+
new VueLoaderPlugin(),
|
|
169
|
+
// 把第三方库暴漏到window context下
|
|
170
|
+
new webpack.ProvidePlugin({
|
|
171
|
+
Vue:'vue',
|
|
172
|
+
axios:'axios',
|
|
173
|
+
_:'lodash',
|
|
174
|
+
}),
|
|
175
|
+
// 定义全局常量
|
|
176
|
+
new webpack.DefinePlugin({
|
|
177
|
+
__VUE_OPTIONS_API__:'true',//支持vue解析optionApi
|
|
178
|
+
__VUE_PROD_DEVTOOLS__:'false',//禁用vue调试工具
|
|
179
|
+
__VUE_PROD_HYDRATION_MISMATCH_DETAILS__:'false',//禁用生产环境水合不匹配详情
|
|
180
|
+
}),
|
|
181
|
+
// 构造最终渲染页面模板
|
|
182
|
+
...elpisHtmlWebpackPluginList,
|
|
183
|
+
...businessHtmlWebpackPluginList
|
|
184
|
+
],
|
|
185
|
+
// 配置打包输出优化 (配置代码分割,模块合并,缓存,TreeShaing,压缩等优化策略)
|
|
186
|
+
optimization: {
|
|
187
|
+
/*
|
|
188
|
+
* 把js打包成3中类型
|
|
189
|
+
* 1 vendor 第三方lib库 基本不会改动,除非依赖版本升级
|
|
190
|
+
* 2 common 业务组件代码的公共部分抽取出来 改动较少
|
|
191
|
+
* 3 entry.{page} 不用页面 entry 里的业务组件代码的差异部分,会经常改动
|
|
192
|
+
* 目的:把改动和引用频率不一样的js区分出来 以达到更好利用浏览器缓存的效果
|
|
193
|
+
* */
|
|
194
|
+
splitChunks: {
|
|
195
|
+
chunks: 'all',//对同步和异步模块进行分割
|
|
196
|
+
maxAsyncRequests:10,//每次异步加载的最大并行请求数
|
|
197
|
+
maxInitialRequests:10,//入口点的最大并行请求数
|
|
198
|
+
cacheGroups: {
|
|
199
|
+
vendor: { //第三方依赖库
|
|
200
|
+
test: /[\\/]node_modules[\\/]/,//打包node_modules中的文件
|
|
201
|
+
name: 'vendor',//模块名称
|
|
202
|
+
priority: 20,//优先级 数字越大,优先级越高
|
|
203
|
+
enforce: true,//强制执行
|
|
204
|
+
reuseExistingChunk: true, //复用已有的公共chunk
|
|
205
|
+
},
|
|
206
|
+
common: { //公共模块
|
|
207
|
+
test: /[\\/]common | widgets[\\/]/,//打包common和widgets中的文件
|
|
208
|
+
name: 'common',//模块名称
|
|
209
|
+
minChunks: 2,//被两处引用即为公共模块
|
|
210
|
+
minSize: 1,//最小分割文件大小 1byte
|
|
211
|
+
priority: 10,//优先级
|
|
212
|
+
reuseExistingChunk: true,//复用已有的公共chunk
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
},
|
|
216
|
+
// 将webpack运行时生成的代码打包到runtime.js
|
|
217
|
+
runtimeChunk:true
|
|
218
|
+
}
|
|
219
|
+
},buinessWebPackConfig)
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
const merge = require('webpack-merge');
|
|
2
|
+
const webpack = require('webpack');
|
|
3
|
+
|
|
4
|
+
// 基础类
|
|
5
|
+
const baseConfig = require('./webpack.base.js');
|
|
6
|
+
const path = require("path");
|
|
7
|
+
// devServer配置
|
|
8
|
+
const DEV_SERVER_CONFIG={
|
|
9
|
+
HOST:'127.0.0.1',
|
|
10
|
+
PORT:9002,
|
|
11
|
+
HMR_PATH:'__webpack_hmr',//官方规定
|
|
12
|
+
TIMEOUT:20000
|
|
13
|
+
}
|
|
14
|
+
const {HOST,PORT,HMR_PATH,TIMEOUT} = DEV_SERVER_CONFIG
|
|
15
|
+
Object.keys(baseConfig.entry).forEach(v=>{
|
|
16
|
+
// 第三方包不作为hmr的入口
|
|
17
|
+
if(v !=='vendor'){
|
|
18
|
+
baseConfig.entry[v] = [
|
|
19
|
+
// 主入口文件
|
|
20
|
+
baseConfig.entry[v],
|
|
21
|
+
// hmr更新入口,官方指定的hmr路径
|
|
22
|
+
`${require.resolve('webpack-hot-middleware/client')}?path=http://${HOST}:${PORT}/${HMR_PATH}&timeout=${TIMEOUT}&reload=true`
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
// 生产环境webpack配置
|
|
28
|
+
const webpackConfig = merge.smart(baseConfig, {
|
|
29
|
+
// 指定开发环境模式
|
|
30
|
+
mode: 'development',
|
|
31
|
+
// sourcemap开发工具,呈现代码的映射关系,便于在开发过程中调试代码
|
|
32
|
+
devtool: 'eval-cheap-module-source-map',
|
|
33
|
+
// 开发阶段的output配置
|
|
34
|
+
output:{
|
|
35
|
+
filename:'js/[name]_[chunkhash:8].bundle.js',
|
|
36
|
+
path:path.resolve(process.cwd(),'./app/public/dist/dev/'),//输出文件路径
|
|
37
|
+
publicPath:`http://${HOST}:${PORT}/public/dist/dev`, //外部资源公共路径
|
|
38
|
+
globalObject: 'this'
|
|
39
|
+
},
|
|
40
|
+
plugins:[
|
|
41
|
+
// HotModuleReplacementPlugin 用于实现热模块替换(Hot Module Replacement 简称 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
|
+
};
|