Created
January 6, 2021 06:29
-
-
Save velotiotech/905faf1de6048c0d9b6c09f732ee00c5 to your computer and use it in GitHub Desktop.
Eliminate render-blocking resources - html-critical-webpack-plugin using craco
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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