Skip to content

Instantly share code, notes, and snippets.

@velotiotech
Created January 6, 2021 06:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save velotiotech/905faf1de6048c0d9b6c09f732ee00c5 to your computer and use it in GitHub Desktop.
Save velotiotech/905faf1de6048c0d9b6c09f732ee00c5 to your computer and use it in GitHub Desktop.
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