Skip to content

Commit

Permalink
Resource hints for SPA
Browse files Browse the repository at this point in the history
  • Loading branch information
Pooya Parsa committed Aug 18, 2017
1 parent d6cb2cb commit 7a9539e
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 10 deletions.
33 changes: 23 additions & 10 deletions lib/builder/webpack/client.config.js
Expand Up @@ -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'

/*
|--------------------------------------------------------------------------
Expand Down Expand Up @@ -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(
Expand All @@ -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({
Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -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",
Expand Down
6 changes: 6 additions & 0 deletions yarn.lock
Expand Up @@ -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"
Expand Down

0 comments on commit 7a9539e

Please sign in to comment.