Skip to content

Commit

Permalink
Fix disabling criticalCSS
Browse files Browse the repository at this point in the history
  • Loading branch information
sneko committed Jun 10, 2022
1 parent 6de3c8e commit 35be587
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,17 @@ 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']
for (const lang of langs) {
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')
Expand All @@ -56,6 +57,7 @@ exports.chainWebpack = (webpackConfig) => {
...htmlPlugin.get('args')[0],
template: config.api.resolve('public/index.ssr.html'),
filename: 'index.ssr.html',
chunks: [],
},
])

Expand Down

0 comments on commit 35be587

Please sign in to comment.