假设我有 3 个由动态导入创建的异步块:
const Notes = lazy(() => import(/* webpackChunkName: "notes" */ 'pages/Notes'))
const Lists = lazy(() => import(/* webpackChunkName: "lists" */ 'pages/Lists'))
const Files = lazy(() => import(/* webpackChunkName: "files" */ 'pages/Files'))
Run Code Online (Sandbox Code Playgroud)
将生成:
notes.g3g43g.js
lists.534535.js
files.234f8t.js
Run Code Online (Sandbox Code Playgroud)
每个块都包含它自己的供应商依赖项。
所以在notes.g3g43g.js里面我们有react-big-calendar和lodash。
但是,当使用 SplitChunksPlugin 时,我们可以将chunks选项设置为all:
optimization: {
runtimeChunk: 'single',
splitChunks: {
chunks: 'all',
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name: ({ context }) => (context.match(/[\\/]node_modules[\\/](.*?)([\\/]|$)/)[1]
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
从这一点来看,react-big-calendar和lodash …
javascript webpack code-splitting html-webpack-plugin splitchunksplugin
很明显,Next.js 对 SSG 页面返回 304 Not Modified HTTP 状态,但它可以对实时渲染的页面执行此操作吗?
反过来说,当最初请求 SSR 页面时,Next.js 是否返回 ETag 标头?
谢谢。