diff --git a/babel.config.js b/babel.config.js index e955840..20c52d1 100644 --- a/babel.config.js +++ b/babel.config.js @@ -1,5 +1,8 @@ module.exports = { presets: [ '@vue/cli-plugin-babel/preset' + ], + plugins: [ + '@babel/plugin-syntax-dynamic-import' ] } diff --git a/package.json b/package.json index 4fa4f09..9bf7eb0 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "vue-table-with-tree-grid": "^0.2.4" }, "devDependencies": { + "@babel/plugin-syntax-dynamic-import": "^7.8.3", "@vue/cli-plugin-babel": "~4.4.0", "@vue/cli-plugin-eslint": "~4.4.0", "@vue/cli-plugin-router": "~4.4.0", diff --git a/src/router/router.js b/src/router/router.js index 340953c..7121b2f 100644 --- a/src/router/router.js +++ b/src/router/router.js @@ -1,23 +1,41 @@ import Vue from 'vue' import VueRouter from 'vue-router' -import Login from '../components/Login' -import Home from '../components/Home' -import welcome from '../components/welcome' -import users from '../components/users/users' -import access from '../components/access/access' -import roles from '../components/access/roles' -import categories from '../components/goods/categories' -import params from '../components/goods/params' -import goods from '../components/goods/goods' -import goodsEdit from '../components/goods/edit' -import order from '../components/order/order' -import report from '../components/report/report' + +// import Login from '../components/Login' +const Login = () => import(/* webpackChunkName: "login-home-welcome" */ '../components/Login') + +// import Home from '../components/Home' +const Home = () => import(/* webpackChunkName: "login-home-welcome" */ '../components/Home') + +// import welcome from '../components/welcome' +const welcome = () => import(/* webpackChunkName: "login-home-welcome" */ '../components/welcome') + +// import users from '../components/users/users' +// import access from '../components/access/access' +// import roles from '../components/access/roles' +const users = () => import(/* webpackChunkName: "login-home-users" */ '../components/welcome') +const access = () => import(/* webpackChunkName: "login-home-users" */ '../components/access/access') +const roles = () => import(/* webpackChunkName: "login-home-users" */ '../components/access/roles') + +// import categories from '../components/goods/categories' +// import params from '../components/goods/params' +// import goods from '../components/goods/goods' +// import goodsEdit from '../components/goods/edit' +const categories = () => import(/* webpackChunkName: "login-home-goods" */ '../components/goods/categories') +const params = () => import(/* webpackChunkName: "login-home-goods" */ '../components/goods/params') +const goods = () => import(/* webpackChunkName: "login-home-goods" */ '../components/goods/goods') +const goodsEdit = () => import(/* webpackChunkName: "login-home-goods" */ '../components/goods/edit') + +// import order from '../components/order/order' +// import report from '../components/report/report' +const order = () => import(/* webpackChunkName: "login-home-order" */ '../components/order/order') +const report = () => import(/* webpackChunkName: "login-home-order" */ '../components/report/report') Vue.use(VueRouter) const routes = [ - { path: '/', redirect: '/login' }, - { path: '/login', component: Login }, + {path: '/', redirect: '/login'}, + {path: '/login', component: Login}, { path: '/home', component: Home, diff --git a/yarn.lock b/yarn.lock index 893606b..bbc6b8a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -377,13 +377,20 @@ dependencies: "@babel/helper-plugin-utils" "^7.10.1" -"@babel/plugin-syntax-dynamic-import@^7.8.0", "@babel/plugin-syntax-dynamic-import@^7.8.3": +"@babel/plugin-syntax-dynamic-import@^7.8.0": version "7.8.3" resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-dynamic-import/-/plugin-syntax-dynamic-import-7.8.3.tgz#62bf98b2da3cd21d626154fc96ee5b3cb68eacb3" integrity sha512-5gdGbFon+PszYzqs83S3E5mpi7/y/8M9eC90MRTZfduQOYW76ig6SOSPNe41IG5LoP3FGBn2N0RjVDSQiS94kQ== dependencies: "@babel/helper-plugin-utils" "^7.8.0" +"@babel/plugin-syntax-dynamic-import@^7.8.3": + version "7.8.3" + resolved "https://registry.npm.taobao.org/@babel/plugin-syntax-dynamic-import/download/@babel/plugin-syntax-dynamic-import-7.8.3.tgz?cache=0&sync_timestamp=1578950368021&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40babel%2Fplugin-syntax-dynamic-import%2Fdownload%2F%40babel%2Fplugin-syntax-dynamic-import-7.8.3.tgz#62bf98b2da3cd21d626154fc96ee5b3cb68eacb3" + integrity sha1-Yr+Ysto80h1iYVT8lu5bPLaOrLM= + dependencies: + "@babel/helper-plugin-utils" "^7.8.0" + "@babel/plugin-syntax-json-strings@^7.8.0": version "7.8.3" resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-json-strings/-/plugin-syntax-json-strings-7.8.3.tgz#01ca21b668cd8218c9e640cb6dd88c5412b2c96a"