Browse Source

fix: do not preload runtime.js (#596)

add runtime.js to fileBlacklist
花裤衩 4 years ago
parent
commit
8e76fdb622
1 changed files with 10 additions and 1 deletions
  1. 10 1
      vue.config.js

+ 10 - 1
vue.config.js

@@ -50,7 +50,15 @@ module.exports = {
50
   },
50
   },
51
   chainWebpack(config) {
51
   chainWebpack(config) {
52
     // it can improve the speed of the first screen, it is recommended to turn on preload
52
     // it can improve the speed of the first screen, it is recommended to turn on preload
53
-    // config.plugins.delete('preload')
53
+    config.plugin('preload').tap(() => [
54
+      {
55
+        rel: 'preload',
56
+        // to ignore runtime.js
57
+        // https://github.com/vuejs/vue-cli/blob/dev/packages/@vue/cli-service/lib/config/app.js#L171
58
+        fileBlacklist: [/\.map$/, /hot-update\.js$/, /runtime\..*\.js$/],
59
+        include: 'initial'
60
+      }
61
+    ])
54
 
62
 
55
     // when there are many pages, it will cause too many meaningless requests
63
     // when there are many pages, it will cause too many meaningless requests
56
     config.plugins.delete('prefetch')
64
     config.plugins.delete('prefetch')
@@ -118,6 +126,7 @@ module.exports = {
118
                 }
126
                 }
119
               }
127
               }
120
             })
128
             })
129
+          // https:// webpack.js.org/configuration/optimization/#optimizationruntimechunk
121
           config.optimization.runtimeChunk('single')
130
           config.optimization.runtimeChunk('single')
122
         }
131
         }
123
       )
132
       )