diff --git a/lib/builder/webpack/client.config.js b/lib/builder/webpack/client.config.js index 2b55d80070bb..7a7e9ba67e92 100644 --- a/lib/builder/webpack/client.config.js +++ b/lib/builder/webpack/client.config.js @@ -7,6 +7,7 @@ import ProgressBarPlugin from 'progress-bar-webpack-plugin' import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer' import { resolve } from 'path' import base from './base.config.js' +import ScriptExtHtmlWebpackPlugin from 'script-ext-html-webpack-plugin' /* |-------------------------------------------------------------------------- @@ -74,6 +75,28 @@ export default function webpackClientConfig () { config.plugins = [] } + // Generate output HTML for SPA + config.plugins.push( + new HTMLPlugin({ + filename: 'index.spa.html', + template: this.options.appTemplatePath, + inject: true, + chunksSortMode: 'dependency' + }) + ) + + // Resource hints for SPA + config.plugins.push( + new ScriptExtHtmlWebpackPlugin({ + preload: [ + 'app', + 'vendor', + 'common', + 'manifest' + ] + }) + ) + // Generate output HTML for SSR if (this.options.build.ssr) { config.plugins.push( @@ -85,16 +108,6 @@ export default function webpackClientConfig () { ) } - // Generate output HTML for SPA - config.plugins.push( - new HTMLPlugin({ - filename: 'index.spa.html', - template: this.options.appTemplatePath, - inject: true, - chunksSortMode: 'dependency' - }) - ) - // Generate vue-ssr-client-manifest config.plugins.push( new VueSSRClientPlugin({ diff --git a/package.json b/package.json index cbe17b7c50fd..685dfa6ba031 100644 --- a/package.json +++ b/package.json @@ -104,6 +104,7 @@ "pretty-error": "^2.1.1", "progress-bar-webpack-plugin": "^1.10.0", "resolve-url-loader": "^2.1.0", + "script-ext-html-webpack-plugin": "^1.8.5", "serialize-javascript": "^1.4.0", "serve-static": "^1.12.4", "server-destroy": "^1.0.1", diff --git a/yarn.lock b/yarn.lock index 99fb6246e91c..7c1ab3026a39 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6039,6 +6039,12 @@ schema-utils@^0.3.0: dependencies: ajv "^5.0.0" +script-ext-html-webpack-plugin@^1.8.5: + version "1.8.5" + resolved "https://registry.yarnpkg.com/script-ext-html-webpack-plugin/-/script-ext-html-webpack-plugin-1.8.5.tgz#7a408383d7f3329da8f59d503be25cc39a53f3f3" + dependencies: + debug "^2.6.8" + semver-diff@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/semver-diff/-/semver-diff-2.1.0.tgz#4bbb8437c8d37e4b0cf1a68fd726ec6d645d6d36"