I have a simple multi-page application with three pages, my webpack.config.js entry looks like this:
{ entry: { a: 'pages/a.js', b: 'pages/b.js', c: 'pages/c.js', } }
Each page consists of several React components, some of which are visible from above on the first render, and some of them are not displayed.
I would like to declaratively determine which components are โcriticalโ (above) for each page / post, and this CSS is extracted to a separate file. Something like:
{ a: ['compononents/button/style.css', ...], b: ['compononents/title/style.css', ...], c: ['compononents/header/style.css', ...] }
output of something like:
- dist/a.critical.css - dist/b.critical.css - dist/c.critical.css
I play with extract-text-webpack-plugin , but it seems I canโt find a way to tell it to only extract specific CSS in the context of a particular post.
How can I extract the specific content of a CSS file if in the context of a particular post / page?
webpack
wilsonpage
source share