Skip to content

Commit 395dd2c

Browse files
committed
refactor: update Webpack config to not calculate Critical CSS while doing local development (watch mode)
1 parent 80d1fe8 commit 395dd2c

File tree

1 file changed

+31
-29
lines changed

1 file changed

+31
-29
lines changed

packages/uikit-workshop/webpack.config.js

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -318,36 +318,38 @@ module.exports = function() {
318318
})
319319
);
320320

321-
webpackConfig.plugins.push(
322-
new CriticalCssPlugin({
323-
base: path.resolve(__dirname, config.buildDir),
324-
src: 'index.html',
325-
dest: 'index.html',
326-
inline: true,
327-
minify: true,
328-
extract: false,
329-
width: 1300,
330-
height: 900,
331-
penthouse: {
332-
keepLargerMediaQueries: true,
321+
if (!argv.watch) {
322+
webpackConfig.plugins.push(
323+
new CriticalCssPlugin({
324+
base: path.resolve(__dirname, config.buildDir),
325+
src: 'index.html',
326+
dest: 'index.html',
327+
inline: true,
328+
minify: true,
329+
extract: false,
330+
width: 1300,
331+
height: 900,
332+
penthouse: {
333+
keepLargerMediaQueries: true,
333334

334-
// @todo: troubleshoot why forceInclude works w/ Penthouse directly but not w/ Critical
335-
forceInclude: [
336-
'pl-logo',
337-
'.pl-c-logo',
338-
'.pl-c-logo__img',
339-
'.pl-c-body--theme-light',
340-
'.pl-c-body--theme-sidebar',
341-
'.pl-c-body--theme-sidebar .pl-c-viewport',
342-
'.pl-c-body--theme-density-compact',
343-
],
344-
timeout: 30000, // ms; abort critical CSS generation after this timeout
345-
maxEmbeddedBase64Length: 1000,
346-
renderWaitTime: 1000,
347-
blockJSRequests: false,
348-
},
349-
})
350-
);
335+
// @todo: troubleshoot why forceInclude works w/ Penthouse directly but not w/ Critical
336+
forceInclude: [
337+
'pl-logo',
338+
'.pl-c-logo',
339+
'.pl-c-logo__img',
340+
'.pl-c-body--theme-light',
341+
'.pl-c-body--theme-sidebar',
342+
'.pl-c-body--theme-sidebar .pl-c-viewport',
343+
'.pl-c-body--theme-density-compact',
344+
],
345+
timeout: 30000, // ms; abort critical CSS generation after this timeout
346+
maxEmbeddedBase64Length: 1000,
347+
renderWaitTime: 1000,
348+
blockJSRequests: false,
349+
},
350+
})
351+
);
352+
}
351353

352354
return resolve(webpackConfig);
353355
});

0 commit comments

Comments
 (0)