Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Eliminate render-blocking resources - html-critical-webpack-plugin using craco
const path = require('path');
const { whenProd } = require('@craco/craco');
const HtmlCriticalWebpackPlugin = require('html-critical-webpack-plugin');
module.exports = {
webpack: {
configure: (webpackConfig) => {
return {
...webpackConfig,
plugins: [
...webpackConfig.plugins,
...whenProd(
() => [
new HtmlCriticalWebpackPlugin({
base: path.resolve(__dirname, 'build'),
src: 'index.html',
dest: 'index.html',
inline: true,
minify: true,
extract: true,
width: 320,
height: 565,
penthouse: {
blockJSRequests: false,
},
}),
],
[]
),
],
};
},
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment