Skip to content

Commit 2ea9d70

Browse files
author
zhongzhenlong
committed
add mock,未完待续
1 parent 25fd455 commit 2ea9d70

22 files changed

+2738
-37
lines changed

.babelrc

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,31 @@
11
{
2-
"presets": ["stage-2"],
3-
"plugins": ["transform-runtime","transform-vue-jsx",["component", [
4-
{
5-
"libraryName": "element-ui",
6-
"styleLibraryName": "~src/css/theme"
7-
}
8-
]]],
2+
"presets": [
3+
"es2015",
4+
"stage-0"
5+
],
6+
"plugins": [
7+
"transform-runtime",
8+
"transform-vue-jsx",
9+
[
10+
"component",
11+
[
12+
{
13+
"libraryName": "element-ui",
14+
"styleLibraryName": "~src/css/theme"
15+
}
16+
]
17+
]
18+
],
919
"comments": false,
1020
"env": {
1121
"test": {
12-
"presets": ["stage-2"],
13-
"plugins": [ "istanbul" ]
22+
"presets": [
23+
"es2015",
24+
"stage-0"
25+
],
26+
"plugins": [
27+
"istanbul"
28+
]
1429
}
1530
}
1631
}

build/dev-client.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
/* eslint-disable */
2+
// 实现浏览器端的EventSource,用于跟服务器双向通信
3+
// webpack热重载客户端跟dev-server上的热重载插件之间需要进行双向通信
4+
// 服务端webpack重新编译后,会向客户端推送信息,告诉客户端进行更新
25
require('eventsource-polyfill')
6+
// webpack热重载客户端
37
var hotClient = require('webpack-hot-middleware/client?noInfo=true&reload=true')
48

9+
// 客户端收到更新动作,执行页面刷新
510
hotClient.subscribe(function (event) {
611
if (event.action === 'reload') {
712
window.location.reload()

build/dev-server.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ var webpack = require('webpack')
1212
var proxyMiddleware = require('http-proxy-middleware')
1313
var webpackConfig = require('./webpack.dev.conf')
1414

15-
// default port where dev server listens for incoming traffic
15+
// 监听http端口
1616
var port = process.env.PORT || config.dev.port
17-
// automatically open browser, if not set will be false
17+
// 是否要自动打开浏览器
1818
var autoOpenBrowser = !!config.dev.autoOpenBrowser
1919
// Define HTTP proxies to your custom API backend
2020
// https://github.com/chimurai/http-proxy-middleware

build/webpack.base.conf.js

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
var path = require('path')
22
var utils = require('./utils')
3-
var config = require('../config')
3+
var config = require('../config/index')
44
var vueLoaderConfig = require('./vue-loader.conf')
55

66
function resolve (dir) {
@@ -9,14 +9,14 @@ function resolve (dir) {
99

1010
module.exports = {
1111
entry: {
12-
app: './src/main.js'
12+
app: './src/main.js',
13+
vendor: [ 'vue', 'vuex', 'vue-router', 'element-ui' ] //第三方库和框架
1314
},
1415
output: {
16+
// path仅仅告诉Webpack结果存储在哪里,然而publicPath项则被许多Webpack的插件用于在生产模式下更新内嵌到css、html文件里的url值。
1517
path: config.build.assetsRoot,
1618
filename: '[name].js',
17-
publicPath: process.env.NODE_ENV === 'production'
18-
? config.build.assetsPublicPath
19-
: config.dev.assetsPublicPath
19+
publicPath: config.dev.assetsPublicPath
2020
},
2121
resolve: {
2222
extensions: ['.js', '.vue', '.json'],
@@ -43,22 +43,31 @@ module.exports = {
4343
{
4444
test: /\.js$/,
4545
loader: 'babel-loader',
46+
exclude: /(node_modules|bower_components)/,
4647
include: [resolve('src'), resolve('test')]
4748
},
4849
{
4950
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
5051
loader: 'url-loader',
51-
query: {
52-
limit: 10000,
53-
name: utils.assetsPath('img/[name].[hash:7].[ext]')
52+
options: {
53+
limit: 5120,
54+
name: utils.assetsPath('img/[name].[ext]')
55+
}
56+
},
57+
{
58+
test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
59+
loader: 'url-loader',
60+
options: {
61+
limit: 10240,
62+
name: utils.assetsPath('media/[name].[ext]')
5463
}
5564
},
5665
{
5766
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
5867
loader: 'url-loader',
59-
query: {
60-
limit: 10000,
61-
name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
68+
options: {
69+
limit: 10240,
70+
name: utils.assetsPath('fonts/[name].[ext]')
6271
}
6372
}
6473
]

build/webpack.dev.conf.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ module.exports = merge(baseWebpackConfig, {
2828
// https://github.com/glenjamin/webpack-hot-middleware#installation--usage
2929
new webpack.HotModuleReplacementPlugin(),
3030
new webpack.NoEmitOnErrorsPlugin(),
31+
new webpack.optimize.CommonsChunkPlugin({
32+
names: ['vendor', 'manifest'],
33+
}),
3134
// https://github.com/ampedandwired/html-webpack-plugin
3235
new HtmlWebpackPlugin({
3336
filename: 'index.html',

build/webpack.prod.conf.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ var webpackConfig = merge(baseWebpackConfig, {
2222
output: {
2323
path: config.build.assetsRoot,
2424
filename: utils.assetsPath('js/[name].[chunkhash].js'),
25-
chunkFilename: utils.assetsPath('js/[id].[chunkhash].js')
25+
chunkFilename: utils.assetsPath('js/[id].[chunkhash].js'),
26+
// path仅仅告诉Webpack结果存储在哪里,然而publicPath项则被许多Webpack的插件用于在生产模式下更新内嵌到css、html文件里的url值。
27+
publicPath: config.build.assetsPublicPath
2628
},
2729
plugins: [
2830
// http://vuejs.github.io/vue-loader/en/workflow/production.html
@@ -41,7 +43,7 @@ var webpackConfig = merge(baseWebpackConfig, {
4143
// }),
4244
// extract css into its own file
4345
new ExtractTextPlugin({
44-
filename: utils.assetsPath('css/[name].[contenthash].css')
46+
filename: utils.assetsPath('css/[name].[hash:7].css')
4547
}),
4648
// Compress extracted CSS. We are using this plugin so that possible
4749
// duplicated CSS from different components can be deduped.

config/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module.exports = {
77
index: path.resolve(__dirname, '../dist/index.html'),
88
assetsRoot: path.resolve(__dirname, '../dist'),
99
assetsSubDirectory: 'static',
10-
assetsPublicPath: '',
10+
assetsPublicPath: '/',
1111
// assetsPublicPath: '/Vue-Admin/',
1212
productionSourceMap: true,
1313
// Gzip off by default as many popular static hosts such as
@@ -27,7 +27,7 @@ module.exports = {
2727
port: 9000,
2828
autoOpenBrowser: false,
2929
assetsSubDirectory: 'static',
30-
assetsPublicPath: '/',
30+
assetsPublicPath: '',
3131
proxyTable: {
3232
// http://localhost:9000/api/menuList => http://localhost:3000/menuList
3333
'/api': {

index.html

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,6 @@
55
<meta http-equiv="X-UA-Compatible" content="IE=edge">
66
<title>Vue-Admin-Demo</title>
77
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
8-
<!-- Polyfills -->
9-
<!--[if lt IE 10]>
10-
<script src="https://as.alipayobjects.com/g/component/??console-polyfill/0.2.2/index.js,es5-shim/4.5.7/es5-shim.min.js,es5-shim/4.5.7/es5-sham.min.js,es6-shim/0.35.1/es6-sham.min.js,es6-shim/0.35.1/es6-shim.min.js,html5shiv/3.7.2/html5shiv.min.js,media-match/2.0.2/media.match.min.js"></script>
11-
<![endif]-->
12-
<!--[if lte IE 11]>
13-
<script src="https://as.alipayobjects.com/g/component/??es6-shim/0.35.1/es6-sham.min.js,es6-shim/0.35.1/es6-shim.min.js"></script>
14-
<![endif]-->
158
</head>
169
<body class="hold-transition skin-blue sidebar-mini">
1710
<div id="root">

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"axios": "^0.16.2",
1717
"babel-polyfill": "^6.26.0",
1818
"echarts": "^3.5.1",
19-
"element-ui": "^1.4.3",
19+
"element-ui": "^1.4.8",
2020
"eventsource-polyfill": "^0.9.6",
2121
"font-awesome": "^4.7.0",
2222
"vue": "^2.4.2",
@@ -39,8 +39,10 @@
3939
"babel-plugin-syntax-jsx": "^6.18.0",
4040
"babel-plugin-transform-runtime": "^6.22.0",
4141
"babel-plugin-transform-vue-jsx": "^3.5.0",
42+
"babel-polyfill": "^6.26.0",
4243
"babel-preset-es2015": "^6.24.1",
4344
"babel-preset-latest": "^6.22.0",
45+
"babel-preset-stage-0": "^6.24.1",
4446
"babel-preset-stage-2": "^6.24.1",
4547
"babel-register": "^6.26.0",
4648
"chalk": "^1.1.3",

src/App.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
</template>
2323

2424
<script>
25-
25+
import 'babel-polyfill'
2626
import Vue from 'vue'
2727
import sideMenu from './components/sideMenu.vue'
2828
import impHeader from "./pages/layout/header.vue"

0 commit comments

Comments
 (0)