Skip to content

Commit

Permalink
fix[chore]: do not preload runtime.js (#3279)
Browse files Browse the repository at this point in the history
  • Loading branch information
PanJiaChen committed Jun 23, 2020
1 parent 5853912 commit 73a9ab0
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion vue.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,16 @@ module.exports = {
},
chainWebpack(config) {
// it can improve the speed of the first screen, it is recommended to turn on preload
// config.plugins.delete('preload')
// it can improve the speed of the first screen, it is recommended to turn on preload
config.plugin('preload').tap(() => [
{
rel: 'preload',
// to ignore runtime.js
// https://github.com/vuejs/vue-cli/blob/dev/packages/@vue/cli-service/lib/config/app.js#L171
fileBlacklist: [/\.map$/, /hot-update\.js$/, /runtime\..*\.js$/],
include: 'initial'
}
])

// when there are many pages, it will cause too many meaningless requests
config.plugins.delete('prefetch')
Expand Down Expand Up @@ -118,6 +127,7 @@ module.exports = {
}
}
})
// https:// webpack.js.org/configuration/optimization/#optimizationruntimechunk
config.optimization.runtimeChunk('single')
}
)
Expand Down

1 comment on commit 73a9ab0

@cuifumin
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

从2020-6-24一直折腾到6-25,在build:prod时生成runtime.js老是报如下错误:
entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (244 KiB). This can impact web performance.
Entrypoints:
app (524 KiB)
static/js/runtime.c2d8544d.js
static/css/chunk-libs.b57e4bfb.css
static/js/chunk-libs.2a87f14a.js
static/css/app.07f9ca88.css
static/js/app.9e2b3985.js
导致index.html无法找到runtime.js。
最终clone了这个版本后才最终解决了问题,webpack的配置真是还有很多需要学习地方。

Please sign in to comment.