简体   繁体   English

Gridsome/Vue.js:如何减少核心包的大小?

[英]Gridsome/Vue.js: How do I reduce the core bundle size?

I'm about to deploy a static Gridsome website.我即将部署一个静态的 Gridsome 网站。 Currently the whole site weighs 518KB (with self-hosted, drastically subsetted fonts, minified inline SVGs, etc) before gzipping.目前,整个站点在 gzip 压缩之前重 518KB(带有自托管、彻底子集化的字体、缩小的内联 SVG 等)。 I know that's already not the most gigantic site of all time, and yet.我知道这已经不是有史以来最庞大的网站,然而。

Running Chrome's code coverage tools, and 88561 bytes of app.js (which totals 181166 bytes) are going unused.运行 Chrome 的代码覆盖工具,以及 88561 字节的 app.js(总共 181166 字节)未使用。 That's nearly 50% of the file.这几乎是文件的 50%。 That's… that's a lot.那是……很多。

I have no dependencies other than Gridsome, and my own JavaScript code is quite light.除了 Gridsome 之外,我没有任何依赖项,而且我自己的 JavaScript 代码很轻。 So I'm given to assume that most of that weight is from Vue.js or Gridsome.所以我假设大部分权重来自 Vue.js 或 Gridsome。 Gridsome already uses Webpack 4 in the back, so I think it's doing a lot of stripping, but still, I'm vexed. Gridsome 已经在后面使用了 Webpack 4,所以我认为它做了很多剥离,但我仍然很烦恼。

Is there anything I can do, or is this just unavoidable?有什么我可以做的,或者这只是不可避免的? Do I need to be writing the whole thing vanilla to bypass this bloat?我是否需要编写整个香草来绕过这种膨胀?

Thanks in advance :)提前致谢 :)

I just started a new Gridsome site, and the app.js file is ~181kB as well.我刚刚开始了一个新的 Gridsome 站点,app.js 文件也是 ~181kB。 Gridsome's docs say: Gridsome 的文档说:

Gridsome adds a 57kB min gzip JS bundle size by default.(vue.js, vue-router, vue-meta and some for image lazy loading). Gridsome 默认添加 57kB 最小 gzip JS 包大小。(vue.js、vue-router、vue-meta 和一些用于图像延迟加载)。

I ran gzip app.js on my built app.js file, and ended up with a 63kB file.我在我构建的 app.js 文件上运行gzip app.js ,最终得到了一个 63kB 的文件。 Based on that, and the fact that the default build is 57kB by default, I think you're not going to end up with a much smaller app.js file without a whole lot of custom work to strip out unused things.基于此,以及默认构建为 57kB 的事实,我认为如果没有大量自定义工作来去除未使用的内容,您不会得到一个更小的 app.js 文件。

I think this is just part of the downside of using prebuilt libraries and frameworks, unfortunately.不幸的是,我认为这只是使用预构建库和框架的缺点的一部分。 That's not to say there aren't ways to improve things, but out of the box it looks like this is what you get.这并不是说没有办法改进事物,而是开箱即用,这看起来就是您所得到的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM