Skip to content

Commit 3e1bb5b

Browse files
author
wangzhaohui
committed
调整打包代码使兼容ie
1 parent b51693f commit 3e1bb5b

File tree

9 files changed

+177
-7287
lines changed

9 files changed

+177
-7287
lines changed

template/client/.editorconfig

Lines changed: 50 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,54 @@
1-
root = true
2-
31
[*]
4-
indent_style = space
5-
indent_size = 2
6-
end_of_line = lf
7-
charset = utf-8
8-
trim_trailing_whitespace = true
9-
insert_final_newline = true
10-
11-
[*.{json,js,vue,html,css}]
12-
indent_size = 2
13-
14-
[*.{java}]
15-
indent_size = 4
2+
charset=utf-8
3+
end_of_line=crlf
4+
trim_trailing_whitespace=true
5+
insert_final_newline=true
6+
indent_style=space
7+
indent_size=4
8+
9+
[{*.sht,*.htm,*.html,*.shtm,*.shtml,*.ng}]
10+
indent_style=space
11+
indent_size=2
12+
13+
[{.babelrc,.stylelintrc,jest.config,*.bowerrc,*.jsb3,*.jsb2,*.json}]
14+
indent_style=space
15+
indent_size=2
16+
17+
[*.js]
18+
indent_style=space
19+
indent_size=2
20+
21+
[{jshint.json,*.jshintrc}]
22+
indent_style=space
23+
indent_size=2
24+
25+
[{tsconfig.app.json,tsconfig.e2e.json,tsconfig.json,tsconfig.spec.json}]
26+
indent_style=space
27+
indent_size=2
28+
29+
[*.js.map]
30+
indent_style=space
31+
indent_size=2
32+
33+
[*.less]
34+
indent_style=space
35+
indent_size=2
36+
37+
[*.scss]
38+
indent_style=space
39+
indent_size=2
40+
41+
[*.vue]
42+
indent_style=space
43+
indent_size=2
44+
45+
[{*.yml,*.yaml}]
46+
indent_style=space
47+
indent_size=2
48+
49+
[.eslintrc]
50+
indent_style=space
51+
indent_size=2
1652

1753
[*.md]
1854
trim_trailing_whitespace = false

template/client/.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
/dist/
2+
/src/common/cookies.js
23
/*.js
34
node_modules/**

template/client/.eslintrc.json

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@
66
"env": {
77
"browser": true
88
},
9+
"globals": {
10+
"localStorage": false,
11+
"Vue": false,
12+
"_": false,
13+
"$": false,
14+
"jQuery": false,
15+
"util": false,
16+
"axios": false
17+
},
918
"extends": [
1019
"plugin:vue/essential",
1120
"standard"
@@ -14,6 +23,25 @@
1423
"vue"
1524
],
1625
"rules": {
17-
"no-new": "off"
26+
"indent": "warn",
27+
"semi": "warn",
28+
"comma-spacing": "warn",
29+
"generator-star-spacing": "off",
30+
"no-caller": "off",
31+
"no-control-regex": "off",
32+
"no-extend-native": "off",
33+
"no-irregular-whitespace": "off",
34+
"no-mixed-operators": "off",
35+
"no-new": "off",
36+
"no-new-func": "off",
37+
"no-unused-vars": "warn",
38+
"new-cap":"warn",
39+
"vue/no-unused-vars": "warn",
40+
"key-spacing": "warn",
41+
"keyword-spacing": "warn",
42+
"space-infix-ops": "warn",
43+
"space-before-blocks": "off",
44+
"space-before-function-paren": "off",
45+
"standard/object-curly-even-spacing": "warn"
1846
}
1947
}

template/client/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ WEB-INF
1010
bower_components
1111
typings
1212
.project
13+
package-lock.json
1314

1415
/bin/
1516
/dist/
@@ -22,3 +23,4 @@ typings
2223
*.iws
2324
*.iml
2425
*.ipr
26+
*.orig

template/client/README.md

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# {{ name }}
22
### 概述
3-
{{ description }}
3+
{{ description }}
44
前端使用用Vue及ElementUI框架,后端实现RESTful规范的接口与前端进行交互。
55
前端工程要配合后端工程提供的接口来使用。
66

@@ -13,11 +13,13 @@
1313
- [Webpack](https://github.com/webpack/webpack)
1414
- [gulp](https://gulpjs.com/)
1515

16+
1617
## 开发流程:
1718
1. 克隆本脚手架前端工程、后端工程,配置数据库,导入示例数据。
1819
1. 根据项目实际需求,配置路由和菜单,准备各路由所对应的vue文件,vue文件内容为空白,待分配给项目成员实现。
19-
1. 实现vue文件的界面部分,暂时使用axios-mock-adapter来拦截ajax请求,返回mock数据,注意mock数据的字段和数据库表设计有关。
20-
1. 后端实现RESTful接口,并维护接口文档(在doc目录下维护raml格式接口文档或使用 http://apizza.cc 在线文档服务)
20+
1. 在mock目录下准备mock数据,设计好数据结构(控件需要的数据结构)和字段名(最好同数据库中表结构字段名,用 java.beans.Introspector.decapitalize 方法处理一下)
21+
1. 实现vue文件的界面部分,使用axios-mock-adapter来拦截ajax请求,返回mock数据。
22+
1. 后端实现RESTful接口,并维护接口文档(在doc目录下维护Swagger格式接口文档或使用 http://apizza.cc 在线文档服务)
2123
1. 前端取消axios-mock-adapter拦截,调试后端接口。
2224

2325
## 注意事项
@@ -40,6 +42,16 @@
4042
目录结构类似 https://github.com/kenberkeley/vue-demo/tree/master/src 但有简化、调整。
4143

4244
```
45+
static
46+
├─lib 第三方库,供页面用<script>引入,不会编译,直接复制到发布目录
47+
│ vue.min.js
48+
│ vue-router.min.js
49+
│ axios.min.js
50+
│ ......
51+
├─assets 资源目录,不会编译,直接复制到发布目录
52+
│ ├─css 公共样式及第三方样式库,页面用<link>引入
53+
│ ├─fonts 图标字体
54+
│ └─images 图片
4355
source
4456
│ index.html 主入口静态页
4557
│ app.js 主入口js
@@ -58,15 +70,6 @@ source
5870
├─components 公共组件
5971
│ toolbar.vue
6072
│ ......
61-
├─lib 第三方库,供页面用<script>引入,不会编译,直接复制到发布目录
62-
│ vue.min.js
63-
│ vue-router.min.js
64-
│ axios.min.js
65-
│ ......
66-
├─assets 资源目录,不会编译,直接复制到发布目录
67-
│ ├─css 公共样式及第三方样式库,页面用<link>引入
68-
│ ├─fonts 图标字体
69-
│ └─images 图片
7073
└─views 所有页面视图
7174
│ app.vue app主视图组件
7275
@@ -136,7 +139,5 @@ Font Awesome 图标
136139
~~http://fontawesome.io/icons/~~
137140
https://www.thinkcmf.com/font/font_awesome/icons.html
138141

139-
RAML 1.0 文档
140-
https://github.com/raml-org/raml-spec/blob/master/versions/raml-10/raml-10.md
141-
142-
142+
Swagger 文档
143+
https://swagger.io/docs/specification/basic-structure/

template/client/gulpfile.js

Lines changed: 44 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -87,36 +87,51 @@ gulp.task('dev', function () {
8787
}
8888
)
8989
})
90-
// 在build模式,仅打包,不监听
91-
gulp.task('build', function () {
92-
process.env.NODE_ENV = process.env.NODE_ENV || 'prod'
93-
runSequence(
94-
'clean',
95-
'copyAssets',
96-
'buildHtml',
97-
function () {
98-
webpackConfig.watch = false
99-
webpackConfig.devtool = undefined
100-
webpackConfig.plugins.push(new webpack.DefinePlugin({
101-
NODE_ENV: 'prod'
102-
}), new BundleAnalyzerPlugin())
103-
webpack(webpackConfig, function (err, stats) {
104-
if (err) {
105-
throw new gutil.PluginError('webpack', err)
90+
function build(faster, analyzer) {
91+
return function(){
92+
process.env.NODE_ENV = process.env.NODE_ENV || 'prod'
93+
runSequence(
94+
'clean',
95+
'copyAssets',
96+
'buildHtml',
97+
function () {
98+
webpackConfig.watch = false
99+
webpackConfig.devtool = undefined
100+
webpackConfig.plugins.push(new webpack.DefinePlugin({
101+
NODE_ENV: 'prod'
102+
}))
103+
if(analyzer){
104+
webpackConfig.plugins.push(new BundleAnalyzerPlugin())
106105
}
107-
gutil.log(
108-
'webpack',
109-
stats.toString({
110-
colors: true,
111-
chunks: false,
112-
hash: false,
113-
version: false
114-
})
115-
)
116-
})
117-
}
118-
)
119-
})
106+
if(faster){
107+
webpackConfig.optimization = webpackConfig.optimization || {}
108+
webpackConfig.optimization.minimizer = []
109+
}
110+
webpack(webpackConfig, function (err, stats) {
111+
if (err) {
112+
throw new gutil.PluginError('webpack', err)
113+
}
114+
gutil.log(
115+
'webpack',
116+
stats.toString({
117+
colors: true,
118+
chunks: false,
119+
hash: false,
120+
version: false
121+
})
122+
)
123+
})
124+
}
125+
)
126+
}
127+
}
128+
// 在build模式,仅打包,不监听
129+
gulp.task('build', build())
130+
// 在build模式,仅打包,不监听,不压缩js,更快一点
131+
gulp.task('buildfaster', build(true))
132+
// 在analyzer模式,仅打包,不监听
133+
gulp.task('analyzer', build(null, true))
134+
120135
gulp.task('webserver', function () {
121136
browserSync.init(dist, {
122137
startPath: '/', // 服务器运行时打开的页面

template/client/package.json

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
"main": "app.js",
77
"scripts": {
88
"dev": "cross-env NODE_ENV=dev gulp dev",
9-
"dev:ie": "cross-env BABEL_ENV=dev:ie gulp dev",
9+
"dev:ie": "cross-env NODE_ENV=dev:ie gulp dev",
1010
"build": "cross-env NODE_ENV=prod gulp build",
11-
"webserver": "cross-env NODE_ENV=dev gulp webserver",
11+
"build:faster": "cross-env NODE_ENV=prod gulp buildfaster",
12+
"analyzer": "cross-env NODE_ENV=prod gulp analyzer",
1213
"webpack": "cross-env NODE_ENV=prod webpack",
1314
"lint": "./node_modules/.bin/eslint --fix --ext .js,.vue ./source/views ./source/components"
1415
},
@@ -29,11 +30,13 @@
2930
"babel-core": "^6.26.0",
3031
"babel-eslint": "8.2.6",
3132
"babel-loader": "^7.1.2",
33+
"babel-plugin-syntax-dynamic-import": "^6.18.0",
3234
"babel-plugin-transform-class-properties": "^6.24.1",
3335
"babel-plugin-transform-object-rest-spread": "^6.26.0",
34-
"babel-plugin-transform-runtime": "^7.0.0-beta.3",
36+
"babel-plugin-transform-runtime": "^6.23.0",
3537
"babel-polyfill": "^6.26.0",
36-
"babel-preset-env": "^1.6.1",
38+
"babel-preset-env": "^1.7.0",
39+
"babel-preset-es2015": "^6.24.1",
3740
"browser-sync": "^2.18.13",
3841
"cross-env": "^5.1.1",
3942
"css-loader": "^0.28.7",
@@ -53,7 +56,7 @@
5356
"gulp-watch": "^4.3.11",
5457
"run-sequence": "^2.2.0",
5558
"style-loader": "^0.19.0",
56-
"url-loader": "^0.6.2",
59+
"url-loader": "^1.1.2",
5760
"vue-loader": "15.2.4",
5861
"vue-template-compiler": "2.5.x",
5962
"webpack": "^4.16.3",
@@ -62,4 +65,4 @@
6265
"yargs": "^10.0.3"
6366
},
6467
"license": "ISC"
65-
}
68+
}

0 commit comments

Comments
 (0)