Skip to content

Commit

Permalink
Dynamic import router components
Browse files Browse the repository at this point in the history
  • Loading branch information
lyyourc committed May 3, 2017
1 parent 84d6c7c commit 4fb8417
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
"browsers": ["last 2 versions"]
}
}]
]
],
"plugins": ["syntax-dynamic-import"]
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"devDependencies": {
"babel-core": "^6.0.0",
"babel-loader": "^6.0.0",
"babel-plugin-syntax-dynamic-import": "^6.18.0",
"babel-preset-env": "^1.4.0",
"babel-preset-latest": "^6.0.0",
"cross-env": "^3.0.0",
Expand Down
9 changes: 7 additions & 2 deletions src/router.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import Vue from 'vue'
import VueRouter from 'vue-router'

import Emoji from './pages/Emoji.vue'
import Photos from './pages/photos.vue'
const Emoji = () => import(
/* webpackChunkName: "Emoji" */
'./pages/Emoji.vue')

const Photos = () => import(
/* webpackChunkName: "Photos" */
'./pages/Photos.vue')


Vue.use(VueRouter)
Expand Down
3 changes: 2 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ module.exports = {
output: {
path: path.resolve(__dirname, './dist'),
// publicPath: '/dist/',
filename: '[name].js'
filename: '[name].js',
chunkFilename: '[name].chunk.js',
},
module: {
rules: [
Expand Down
4 changes: 4 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,10 @@ babel-plugin-syntax-async-functions@^6.8.0:
version "6.13.0"
resolved "http://registry.npm.taobao.org/babel-plugin-syntax-async-functions/download/babel-plugin-syntax-async-functions-6.13.0.tgz#cad9cad1191b5ad634bf30ae0872391e0647be95"

babel-plugin-syntax-dynamic-import@^6.18.0:
version "6.18.0"
resolved "http://registry.npm.taobao.org/babel-plugin-syntax-dynamic-import/download/babel-plugin-syntax-dynamic-import-6.18.0.tgz#8d6a26229c83745a9982a441051572caa179b1da"

babel-plugin-syntax-exponentiation-operator@^6.8.0:
version "6.13.0"
resolved "http://registry.npm.taobao.org/babel-plugin-syntax-exponentiation-operator/download/babel-plugin-syntax-exponentiation-operator-6.13.0.tgz#9ee7e8337290da95288201a6a57f4170317830de"
Expand Down

0 comments on commit 4fb8417

Please sign in to comment.