Ant-design-pro: 关于code splitting首次加载下载过多js文件

Created on 17 Nov 2017  ·  7Comments  ·  Source: ant-design/ant-design-pro

下载最新代码,ant-design-pro加入了code splitting,但是加载首屏时,下载大量的js文件,加入code splitting的目的是让用户加载首屏更快,但是加载首屏需要发送这么多js文件请求,是不是可以减少首屏js请求?

2017-11-17 3 07 27

Most helpful comment

这个是我的锅,我来更新下文档,之前忽略了,不能直接 import,得 ()=>import,要不然直接执行返回结果了

All 7 comments

https 就好了

@nikogu @WhatAKitty 发现一个问题,code splitting 后,有些内容重复打包了,例如一些 antd 组件。导致加载的总体积大大超过 splitting 之前。

https://preview.pro.ant.design/17.async.js
https://preview.pro.ant.design/20.async.js

@afc163 打包的话,可能涉及到rodhog那方面,需要问下@sorrycc

没研究过rodhog里面具体的打包情况,webpack打包的话,需要配置插件

new webpack.optimize.CommonsChunkPlugin({
            name: 'index',
            children: true,
            async: true
        }),

刚看了下,跟 roadhog 以及 webpack 应该没啥关系,是 pro 的 navData 写法有问题:https://github.com/ant-design/ant-design-pro/blob/master/src/router.js#L42

这样写,可能 router 到 User,但是 BasicLayout 依旧会加载进来,并且里面的 children 也会,这个我看看怎么改下。 一本正经胡说八道...

这个是我的锅,我来更新下文档,之前忽略了,不能直接 import,得 ()=>import,要不然直接执行返回结果了

哈哈,确实应该返回一个方法,这样等到路由需要这个组件的时候才会动态的加载该组件对应的js文件

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Jerry-goodboy picture Jerry-goodboy  ·  3Comments

suifan picture suifan  ·  3Comments

skyFi picture skyFi  ·  3Comments

renyi818 picture renyi818  ·  3Comments

yjz1004 picture yjz1004  ·  3Comments