Question: Is there any way to only extract the css files from initial chunk?
See original GitHub issueI don’t think the browser needs to make extra an request to fetch the css file of its own async js chunk which it has been loaded. So I want to disable.
It should be something like the “fallback” option of extract-text-webpack-plugin
and its behavior. However, I’m not able to find an equivalent way with mini-css-extract-plugin
and webpack 4.
For example, let’s say we have several pages will be loaded on demand:
// routes.js inside intial-chunk.js
import './initial-chunk.css';
const routes: [
{
module: () => import('pageA')
}
];
// pageA.js
import './pageA.css';
export default {
// something that pageA should do
};
// pageB.js
import './pageB.css';
export default {
// something that pageB should do
};
And the output files should be like this:
vendor.js
initial-chunk.js
initial-chunk.css
pageA.js
pageB.js
// Note that there isn't a "pageA.css" or "pageB.css" file. These css files are inside their own chunks and loaded by some other loaders, `style-loader` for example
How can I achieve this? Thank you very much.
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (1 by maintainers)
Top Results From Across the Web
extracting one css file per webpack chunk (require.ensure)
By passing {allChunks: true} it extracts all the css in all the chunks and puts in one css file. But it doesn't solve...
Read more >Separating CSS - SurviveJS
Webpack provides a means to generate a separate CSS bundles using mini-css-extract-plugin (MCEP). It can aggregate multiple CSS files into one.
Read more >extract-css-chunks-webpack-plugin - npm
Extract CSS from chunks into stylesheets + HMR. Supports Webpack 4 + SSR. Latest version: 4.9.0, last published: 2 years ago.
Read more >How Do You Remove Unused CSS From a Site?
To clean CSS with multiple pages just use that tool for all pages with different layouts. Then merge all exported CSS files to...
Read more >9 tricks to eliminate render blocking resources - LogRocket Blog
The @import rule lets you import CSS from other stylesheets, but this causes the browser to process your CSS file more slowly because...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Was there a resolution on this? We have a bunch of dynamic imports, and they’re each getting their own CSS files and I’d like to bubble them up to their closest entrypoint, but haven’t been able to find the right config to achieve it.
No, I want to load css modules only when you need