From d19fb4f21553e01a83a7709d5c2aeb3c47817275 Mon Sep 17 00:00:00 2001 From: Philip Waritschlager Date: Mon, 23 Mar 2020 13:25:42 +0100 Subject: [PATCH 1/2] Always remove extract-css-loader on server ... even when `cricitcalCSS` is disabled. This fixes the `document is not defined` bug in production mode Fixes #186 --- lib/webpack.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/webpack.js b/lib/webpack.js index 2e4993d..40ecd24 100644 --- a/lib/webpack.js +++ b/lib/webpack.js @@ -24,7 +24,7 @@ exports.chainWebpack = (webpackConfig) => { webpackConfig.plugins.delete('friendly-errors') const isExtracting = webpackConfig.plugins.has('extract-css') - if (isExtracting && config.criticalCSS) { + if (isExtracting) { // Remove extract const langs = ['css', 'postcss', 'scss', 'sass', 'less', 'stylus'] const types = ['vue-modules', 'vue', 'normal-modules', 'normal'] @@ -32,8 +32,9 @@ exports.chainWebpack = (webpackConfig) => { for (const type of types) { const rule = webpackConfig.module.rule(lang).oneOf(type) rule.uses.delete('extract-css-loader') - // Critical CSS - rule.use('css-context').loader(CssContextLoader).before('css-loader') + if (config.criticalCSS) { + rule.use('css-context').loader(CssContextLoader).before('css-loader') + } } } webpackConfig.plugins.delete('extract-css') From d387e67b147a30ddfaef5f045727adbee36b7e45 Mon Sep 17 00:00:00 2001 From: bogdantica <38131900+bogdantica@users.noreply.github.com> Date: Sun, 10 May 2020 00:12:14 +0300 Subject: [PATCH 2/2] Update webpack.js --- lib/webpack.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/webpack.js b/lib/webpack.js index 40ecd24..d207485 100644 --- a/lib/webpack.js +++ b/lib/webpack.js @@ -57,6 +57,7 @@ exports.chainWebpack = (webpackConfig) => { ...htmlPlugin.get('args')[0], template: config.api.resolve('public/index.ssr.html'), filename: 'index.ssr.html', + chunks: [], }, ])