lincenying / vue2-multiple-entry

vue2, vue2+vue-router, vue2+vue-router+vuex 混合多页配置实例
https://lincenying.github.io/vue2-multiple-entry/index
150 stars 55 forks source link

这种情况下,如何加个单页的代码分割功能 #2

Closed wbcz closed 7 years ago

wbcz commented 7 years ago

我发现基于这个架构,做单页的代码分割好像不容易,不知道楼主有什么解决办法

lincenying commented 7 years ago

一般用路由了才需要分割代码, 把分割代码放在modules/xxx/router/index.js里就行了.

lincenying commented 7 years ago

https://github.com/lincenying/vue2-multiple-entry/blob/dev/src/modules/vuex/router/index.js#L4-L5

wbcz commented 7 years ago

const index = resolve => { require.ensure(['./../pages/index.vue'], () => { resolve(require('./../pages/index.vue')) }) } const view = resolve => { require.ensure(['./../pages/view.vue'], () => { resolve(require('./../pages/view.vue')) }) }

用古老的写法怎么不行呢,难道webpack2不兼容?but,他是兼容CommonJS写法的啊

lincenying commented 7 years ago

本仓库用的是webpack2, 请按上面发的链接里的写法写.