refactor router

This commit is contained in:
Pan 2017-12-20 11:43:32 +08:00
parent 2161d22630
commit cc069d18a4
5 changed files with 12 additions and 16 deletions

View File

@ -8,12 +8,10 @@
}], }],
"stage-2" "stage-2"
], ],
"plugins":["transform-vue-jsx", "transform-runtime"],
"env": { "env": {
"development":{ "development":{
"plugins": ["transform-vue-jsx", "transform-runtime", "dynamic-import-node"] "plugins": ["dynamic-import-node"]
},
"production": {
"plugins": ["transform-vue-jsx", "transform-runtime"]
} }
} }
} }

View File

@ -7,8 +7,8 @@
"scripts": { "scripts": {
"dev": "cross-env BABEL_ENV=development webpack-dev-server --inline --progress --config build/webpack.dev.conf.js", "dev": "cross-env BABEL_ENV=development webpack-dev-server --inline --progress --config build/webpack.dev.conf.js",
"start": "npm run dev", "start": "npm run dev",
"build": "cross-env BABEL_ENV=production node build/build.js", "build": "node build/build.js",
"build:report": "cross-env BABEL_ENV=production npm_config_report=true node build/build.js", "build:report": "npm_config_report=true node build/build.js",
"lint": "eslint --ext .js,.vue src", "lint": "eslint --ext .js,.vue src",
"test": "npm run lint" "test": "npm run lint"
}, },
@ -36,7 +36,7 @@
"babel-preset-stage-2": "6.24.1", "babel-preset-stage-2": "6.24.1",
"chalk": "2.3.0", "chalk": "2.3.0",
"copy-webpack-plugin": "4.2.3", "copy-webpack-plugin": "4.2.3",
"cross-env": "^5.1.1", "cross-env": "5.1.1",
"css-loader": "0.28.7", "css-loader": "0.28.7",
"eslint": "4.13.1", "eslint": "4.13.1",
"eslint-friendly-formatter": "3.0.0", "eslint-friendly-formatter": "3.0.0",

View File

@ -1 +0,0 @@
module.exports = file => require('@/views/' + file + '.vue').default // vue-loader at least v13.0.0+

View File

@ -1 +0,0 @@
module.exports = file => () => import('@/views/' + file + '.vue')

View File

@ -1,6 +1,6 @@
import Vue from 'vue' import Vue from 'vue'
import Router from 'vue-router' import Router from 'vue-router'
const _import = require('./_import_' + process.env.NODE_ENV)
// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading; // in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading // detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading
@ -19,8 +19,8 @@ import Layout from '../views/layout/Layout'
} }
**/ **/
export const constantRouterMap = [ export const constantRouterMap = [
{ path: '/login', component: _import('login/index'), hidden: true }, { path: '/login', component: () => import('@/views/login/index'), hidden: true },
{ path: '/404', component: _import('404'), hidden: true }, { path: '/404', component: () => import('@/views/404'), hidden: true },
{ {
path: '/', path: '/',
@ -30,7 +30,7 @@ export const constantRouterMap = [
hidden: true, hidden: true,
children: [{ children: [{
path: 'dashboard', path: 'dashboard',
component: _import('dashboard/index') component: () => import('@/views/dashboard/index')
}] }]
}, },
@ -44,13 +44,13 @@ export const constantRouterMap = [
{ {
path: 'table', path: 'table',
name: 'Table', name: 'Table',
component: _import('table/index'), component: () => import('@/views/table/index'),
meta: { title: 'Table', icon: 'table' } meta: { title: 'Table', icon: 'table' }
}, },
{ {
path: 'tree', path: 'tree',
name: 'Tree', name: 'Tree',
component: _import('tree/index'), component: () => import('@/views/tree/index'),
meta: { title: 'Tree', icon: 'tree' } meta: { title: 'Tree', icon: 'tree' }
} }
] ]
@ -63,7 +63,7 @@ export const constantRouterMap = [
{ {
path: 'index', path: 'index',
name: 'Form', name: 'Form',
component: _import('form/index'), component: () => import('@/views/form/index'),
meta: { title: 'Form', icon: 'form' } meta: { title: 'Form', icon: 'form' }
} }
] ]