Next.js - 捆绑包太大 (~3MB)

Next.js - Bundle Size too Large (~3MB)

我想问问有没有什么方法可以瘦我的Next.JS包。 尤其是节点模块 - 这会导致浏览器加载如此多的 MB,从而减慢初始浏览速度。

分析如下:

欢迎您随时提供更多信息。

看起来您正在使用 webpack,这里有一些尝试:

Code Splitting

Code splitting is one of the most compelling features of webpack. This feature allows you to split your code into various bundles which can then be loaded on demand or in parallel. It can be used to achieve smaller bundles and control resource load prioritization which, if used correctly, can have a major impact on load time.

Tree Shaking

Tree shaking is a term commonly used in the JavaScript context for dead-code elimination. It relies on the static structure of ES2015 module syntax, i.e. import and export. The name and concept have been popularized by the ES2015 module bundler rollup.