You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by GitBox <gi...@apache.org> on 2020/11/26 02:32:14 UTC

[GitHub] [incubator-weex] wulie88 opened a new issue #3305: 一个让weex打包后js文件减少220KB的方法

wulie88 opened a new issue #3305:
URL: https://github.com/apache/incubator-weex/issues/3305


   我是吴烈,从2017年开始使用Weex,非常感谢这个开源项目。
   
   
   ## Describe the bug
   
   最近在研究jsfm时候发现自带Vue环境,而Weex Cli打包时候又内置了Vue,运行时重复,造成js文件体积大。
   
   目前我是通过Webpack设置成外部Vue,再打包,生成的页面js体积减少220KB,只有业务代码,我们代码控制在100KB以内,以上是没有压缩的情况下,开启gzip后几乎不要流量。
   
   在iOS及安卓上测试通过。
   
   ```
   externals: {
       'vue': 'Vue'
   },
   ```
   
   ps:请加在WeexConfig的webpack中,WebConfig还是需要内置Vue
   
   ## Environment
   
   * weex cli: 2.0.0-beta.31 (Core 2.0.0-beta.31)
   * multipages
   
   使用最新的weex cli配置的多页应用。
   
   ## Screenshots
   
   ![BB5D850D-5D96-463C-9850-DCC307C20B33](https://user-images.githubusercontent.com/783824/100301040-427c1d80-2fd2-11eb-923e-48c3d2faa3af.png)
   ![CE56A255-04BB-425E-8987-06C9F7B0E25A](https://user-images.githubusercontent.com/783824/100301044-4445e100-2fd2-11eb-9508-947644e91ef7.png)
   
   ## Additional context
   
   大家都可以试试,有问题发评论,我会及时回复。
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-weex] wulie88 commented on issue #3305: 一个让weex打包后js文件减少220KB的方法

Posted by GitBox <gi...@apache.org>.
wulie88 commented on issue #3305:
URL: https://github.com/apache/incubator-weex/issues/3305#issuecomment-734053009


   > 如果可以的话,辛苦贴一下webpack的配置及相关版本,本地验证后无效。
   > 我这边的做法是增加tree shaking配置,也减少了很大一部分包体积。
   
   正常打包时候不会内置,引入了Vue当eventBus才会出现内置Vue。我补充说明了。


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-weex] cnryb closed issue #3305: 一个让weex打包后js文件减少220KB的方法

Posted by GitBox <gi...@apache.org>.
cnryb closed issue #3305:
URL: https://github.com/apache/incubator-weex/issues/3305


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-weex] Handandbrainofking commented on issue #3305: 一个让weex打包后js文件减少220KB的方法

Posted by GitBox <gi...@apache.org>.
Handandbrainofking commented on issue #3305:
URL: https://github.com/apache/incubator-weex/issues/3305#issuecomment-738669881


   > 如果可以的话,辛苦贴一下webpack的配置及相关版本,本地验证后无效。
   > 我这边的做法是增加tree shaking配置,也减少了很大一部分包体积。
   
   weex工程tree shaking 的webpack配置可以贴一下吗?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-weex] Handandbrainofking commented on issue #3305: 一个让weex打包后js文件减少220KB的方法

Posted by GitBox <gi...@apache.org>.
Handandbrainofking commented on issue #3305:
URL: https://github.com/apache/incubator-weex/issues/3305#issuecomment-738670467


   直接在webpack中设备external,观察到打包出来的boundle的体积还是一样大,没变化


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-weex] cnryb commented on issue #3305: 一个让weex打包后js文件减少220KB的方法

Posted by GitBox <gi...@apache.org>.
cnryb commented on issue #3305:
URL: https://github.com/apache/incubator-weex/issues/3305#issuecomment-734526540


   可以尝试一下 JSService,可以大幅度降低 js bundle 体积。
   https://weex.apache.org/zh/docs/api/js-service.html


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-weex] wulie88 commented on issue #3305: 一个让weex打包后js文件减少220KB的方法

Posted by GitBox <gi...@apache.org>.
wulie88 commented on issue #3305:
URL: https://github.com/apache/incubator-weex/issues/3305#issuecomment-734053757


   > 如果可以的话,辛苦贴一下webpack的配置及相关版本,本地验证后无效。
   > 我这边的做法是增加tree shaking配置,也减少了很大一部分包体积。
   
   正常打包时候不会内置,自己引入了Vue才会出现内置Vue,如:引入了Vue当eventBus,我补充说明了。


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-weex] BBBOND commented on issue #3305: 一个让weex打包后js文件减少220KB的方法

Posted by GitBox <gi...@apache.org>.
BBBOND commented on issue #3305:
URL: https://github.com/apache/incubator-weex/issues/3305#issuecomment-734048623


   如果可以的话,辛苦贴一下webpack的配置及相关版本,本地验证后无效。
   我这边的做法是增加tree shaking配置,也减少了很大一部分包体积。


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-weex] wulie88 commented on issue #3305: 一个让weex打包后js文件减少220KB的方法

Posted by GitBox <gi...@apache.org>.
wulie88 commented on issue #3305:
URL: https://github.com/apache/incubator-weex/issues/3305#issuecomment-739131684


   > 直接在webpack中设备external,观察到打包出来的boundle的体积还是一样大,没变化
   
   - 如果你没有手动引用Vue,`weex-loader`不会引入Vue,是正确的;
   - 如果你手动引用Vue,如当EventBus,`weex-loader`不知道外部有Vue会引入Vue,是错误的。
   
   你可以在代码中加入如下几行测试,注意打包后的代码内容及文件尺寸。
   
   ```
   import Vue from 'vue';
   export default new Vue();
   ```
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-weex] wulie88 removed a comment on issue #3305: 一个让weex打包后js文件减少220KB的方法

Posted by GitBox <gi...@apache.org>.
wulie88 removed a comment on issue #3305:
URL: https://github.com/apache/incubator-weex/issues/3305#issuecomment-734053009


   > 如果可以的话,辛苦贴一下webpack的配置及相关版本,本地验证后无效。
   > 我这边的做法是增加tree shaking配置,也减少了很大一部分包体积。
   
   正常打包时候不会内置,引入了Vue当eventBus才会出现内置Vue。我补充说明了。


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org