From f55dd06f5ac0c4f5ee97f80061681fc7d96fbc49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8A=B1=E8=A3=A4=E8=A1=A9?= Date: Tue, 23 Jun 2020 21:12:44 +0800 Subject: [PATCH] fix[chore]: do not preload runtime.js (#3279) --- vue.config.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/vue.config.js b/vue.config.js index 6733dd50..68b3e99e 100644 --- a/vue.config.js +++ b/vue.config.js @@ -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') @@ -118,6 +127,7 @@ module.exports = { } } }) + // https:// webpack.js.org/configuration/optimization/#optimizationruntimechunk config.optimization.runtimeChunk('single') } )