Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/guide/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ module.exports = {
defaultTitle: 'My app',
// Path to favicon
favicon: './public/favicon.ico',
// Enable Critical CSS
criticalCSS: true,
// Skip some requests from being server-side rendered
skipRequests: req => req.originalUrl === '/graphql',
// See https://ssr.vuejs.org/guide/build-config.html#externals-caveats
Expand Down
1 change: 1 addition & 0 deletions lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module.exports = {
entry: target => `./src/entry-${target}`,
defaultTitle: 'My app',
favicon: './public/favicon.ico',
criticalCSS: true,
skipRequests: req => req.originalUrl === '/graphql',
nodeExternalsWhitelist: [/\.css$/, /\?vue&type=style/],
applyDefaultServer: true,
Expand Down
17 changes: 15 additions & 2 deletions lib/dev-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,13 @@ module.exports.setupDevServer = ({ server, templatePath, onUpdate }) => new Prom
jsonStats.warnings.forEach(err => console.warn(err))
}
if (stats.hasErrors()) return

// Fix dev server render error when a custom path is used for the server-renderer bundles
const ssrPlugin = (clientConfig.plugins.find((p) => (p.__pluginName || p.constructor.name) === 'ssr') || {}).options || {}

clientManifest = JSON.parse(readFile(
devMiddleware.fileSystem,
'vue-ssr-client-manifest.json'
(ssrPlugin && ssrPlugin.filename) || 'vue-ssr-client-manifest.json'
))

// HTML Template
Expand Down Expand Up @@ -109,8 +113,17 @@ module.exports.setupDevServer = ({ server, templatePath, onUpdate }) => new Prom
jsonStats.warnings.forEach(err => console.warn(err))
}
if (stats.hasErrors()) return

// Try to find ssr plugin config options
// to fix dev server render error when a custom path is used for the server-renderer bundles
const ssrPlugin = (serverConfig.plugins.find((p) => (p.__pluginName || p.constructor.name) === 'ssr') || {}).options || {}

// read bundle generated by vue-ssr-webpack-plugin
serverBundle = JSON.parse(readFile(serverMfs, 'vue-ssr-server-bundle.json'))
serverBundle = JSON.parse(readFile(
serverMfs,
(ssrPlugin && ssrPlugin.filename) || 'vue-ssr-server-bundle.json'
))

update()
onCompilationCompleted()
})
Expand Down
2 changes: 1 addition & 1 deletion lib/webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ exports.chainWebpack = (webpackConfig) => {
webpackConfig.plugins.delete('friendly-errors')

const isExtracting = webpackConfig.plugins.has('extract-css')
if (isExtracting) {
if (isExtracting && config.criticalCSS) {
// Remove extract
const langs = ['css', 'postcss', 'scss', 'sass', 'less', 'stylus']
const types = ['vue-modules', 'vue', 'normal-modules', 'normal']
Expand Down