mini-css-extract-plugin
Lightweight CSS extraction plugin
A webpack plugin that pulls CSS out of JavaScript bundles into separate cacheable files, speeding up sites and supporting per-chunk styles for code-split apps.
This is a tool that helps web developers organize CSS files during the build process. When you're building a website, you often write CSS alongside your JavaScript. This plugin takes all that CSS and pulls it out into separate files, so the styles load independently from the code—which makes websites faster and easier to cache.
Here's what happens behind the scenes: when you're bundling your project with webpack (a popular build tool), this plugin intercepts your CSS files and extracts them into their own dedicated output files. Instead of CSS being embedded inside your JavaScript bundles, it becomes separate .css files that browsers can request and cache separately. This matters because CSS doesn't change as often as JavaScript, so users don't have to re-download styles every time your code updates.
The plugin is particularly useful if you're building a modern web app with code-splitting—that is, breaking your JavaScript into chunks that load only when needed. It can create a CSS file for each chunk, so users only download the styles they actually need. It also supports advanced features like detecting CSS that's already been loaded (helpful if your server is sending CSS directly), combining all CSS into one file if you prefer, and setting up long-term caching using file hashes.
Compared to older extraction tools, this one is designed to be lighter and faster. It doesn't duplicate CSS when compiling, and it works more naturally with webpack 4's build system. The tradeoff is that it requires webpack 4 or later—it won't work with older versions. The README also notes that hot-reloading (refreshing styles instantly during development) isn't yet supported.
Where it fits
- Extract CSS from webpack bundles into separate .css files so browsers can cache styles independently of code.
- Generate a CSS file per code-split chunk so users only download the styles they actually need.
- Set up long-term browser caching for stylesheets using file hashes.