mini-css-extract-plugin

A Webpack 5 plugin that extracts imported CSS into separate files per chunk, with async loading, source maps, and on-demand delivery.

Tool
npm
v2.10.2
4,657 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
65 /100 Good
Development Activity 40
Maintenance 48
Community 72
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
79 /100 Good
Architecture 85
Code Quality 88
Innovation 62
Learning Curve 80

mini-css-extract-plugin is the standard way to pull CSS out of a Webpack 5 bundle and into its own .css files instead of inlining styles into JavaScript. It creates one output CSS file per JS chunk that imports styles, so stylesheets can be requested in parallel with scripts and cached independently across deploys.

Built on Webpack 5’s module and chunk-graph APIs rather than child-compiler hacks used by its predecessor (extract-text-webpack-plugin), it supports async/on-demand loading of CSS for code-split chunks, hot module replacement for standalone stylesheets and CSS Modules during development, and both automatic and manual conflict-order warnings when the same class is defined across multiple imported stylesheets.

The project is maintained by the core Webpack team (sokra, alexander-akait) and ships as both a plugin (registered in plugins) and a loader (referenced in module.rules) from a single package, with generated TypeScript declarations and an extensive Jest test suite covering HMR, attribute injection, ordering, and runtime chunk loading.

As of the current release the maintainers have flagged the project as deprecated in favor of Webpack’s now-native CSS support (experiments.css), though existing configurations continue to work unchanged and migration is opt-in per-rule.

What You Get

  • A MiniCssExtractPlugin class registered in webpack.config.js plugins, paired with MiniCssExtractPlugin.loader in module.rules to intercept CSS imports
  • Per-chunk CSS file output with configurable filename/chunkFilename templates, including function-based naming and content-hash based long-term caching
  • Async/on-demand loading of CSS for code-split (non-initial) chunks via a generated Webpack runtime module, including preload/prefetch link injection
  • Hot Module Replacement support for standalone stylesheets and CSS Modules locals during development, without needing HotModuleReplacementPlugin
  • Conflicting-order detection between chunks that import the same CSS in different sequences, with an ignoreOrder escape hatch for CSS-Modules-scoped projects
  • Named ES module exports for CSS Modules locals (esModule/namedExport), letting bundlers tree-shake unused class-name bindings

Common Use Cases

  • Extracting production CSS from a Webpack 5 app so styles load in parallel with scripts instead of being inlined and executed via JS
  • Splitting CSS per async route/chunk in a code-split single-page app so users only download stylesheets for the routes they visit
  • Combining with css-loader, postcss-loader, and sass-loader in a dev/prod dual configuration (style-loader in dev for fast HMR, mini-css-extract-plugin in prod for cacheable files)
  • Consolidating all CSS into one bundle via optimization.splitChunks cache groups with type: "css/mini-extract" for simpler <link> wiring
  • Server-side rendering setups that need to detect and avoid re-loading CSS already inlined or linked during SSR

Under The Hood

Architecture The plugin hooks into Webpack 5’s compiler and compilation lifecycle rather than the bundle-time module wrapping used by its extract-text-webpack-plugin predecessor: src/index.js defines a CssModule/CssDependency pair registered per-compiler via getCssModule/getCssDependency (cached in a WeakMap keyed on the webpack instance so multiple integrations share one class), taps compilation.hooks.renderManifest to emit one CSS asset per chunk containing CSS-typed modules, and taps runtimeRequirementInTree for ensureChunkHandlers/hmrDownloadUpdateHandlers/prefetchChunkHandlers/preloadChunkHandlers to inject a generated CssLoadingRuntimeModule that creates <link> tags at runtime for async CSS chunks. src/loader.js is a separate pitching loader that either runs a child compiler (createChildCompiler) or, when experimentalUseImportModule is enabled, uses Webpack’s newer this.importModule API to execute the CSS-emitting module and hand its exported locals/dependencies back to the plugin via addDependency. A sortModules topological sort orders CSS modules per chunk group and falls back to a best-effort match with a compilation warning when import order conflicts across entry points.

Tech Stack The package is plain CommonJS JavaScript compiled with Babel (@babel/cli/@babel/preset-env) into dist/, with hand-written TypeScript declarations generated separately via tsc --declaration --emitDeclarationOnly into types/. Its only runtime dependencies are schema-utils (for loader-options.json/plugin-options.json JSON-schema option validation) and tapable (SyncWaterfallHook for the beforeTagInsert/linkPreload/linkPrefetch public extension hooks); webpack itself is a peer dependency pinned to ^5.0.0. The dev toolchain runs Jest with jest-environment-jsdom and memfs for in-memory filesystem test fixtures, cross-env for platform-independent env vars, and standard-version for release automation.

Code Quality Testing is extensive: 18 top-level Jest suites (HMR.test.js, runtime-option.test.js, ignoreOrder-option.test.js, hooks.test.js, validate-plugin-options.test.js, and more) plus a test/cases directory of full webpack-config fixture builds compared against snapshots, run under test:coverage with collectCoverageFrom="src/**/*.js". Options are validated at runtime through schema-utils against committed JSON schemas rather than ad hoc checks, giving structured, descriptive validation errors. Linting combines ESLint (eslint-config-webpack, run through the project’s own dogfooded config) with Prettier and cspell for spelling, all wired into a single npm run lint and enforced in GitHub Actions CI (nodejs.yml) alongside a separate dependency-review.yml workflow; a commitlint conventional-commit check also gates commits via Husky.

What Makes It Unique Unlike its predecessor, it avoids spinning up a child compiler for every module by default when experimentalUseImportModule is available (auto-enabled from Webpack 5.52.0), instead executing CSS modules through Webpack’s native importModule API for a meaningful build-performance and memory improvement. It’s also one of the few Webpack plugins that generates its own runtime module (CssLoadingRuntimeModule) to teach the Webpack chunk-loading runtime how to fetch, dedupe, and hot-swap CSS <link> tags for async chunks, rather than only handling the synchronous asset-emission side of the problem — including deduping against <link>/<style> tags already present in the DOM at load time, which is what makes it usable for SSR use cases where critical CSS is inlined server-side.

Used by 35 apps in this directory

PHP
82%
Other

Akaunting

Invoicing Finance

10,149

Open-source online accounting for small businesses and freelancers — invoices, expenses, and reporting without monthly fees or vendor lock-in.

View details
98
Repo Health
73
Technical
63
Dependency
Built with
PHP 82%
Blade 13%
Updated 5 days ago
JavaScript
94%
MIT

Another Redis Desktop Manager

Databases · Developer Tools

34,787

Fast, stable Redis GUI with cluster, SSH, and massive key support

View details
81
Repo Health
56
Technical
67
Dependency
Built with
JavaScript 94%
Updated 1 months ago
TypeScript
68%
Apache 2.0

Appsmith

Automation · Developer Tools · No Code Platforms

40,959

Open-source low-code platform to build admin panels, dashboards, and internal tools connected to any database or API.

View details
93
Repo Health
79
Technical
66
Dependency
Built with
TypeScript 68%
Java 21%
Updated 6 days ago
C#
84%
Other

Bitwarden Server

Password Manager · Security

20,210

Self-hosted, open-source password management backend with zero-knowledge encryption and enterprise-grade identity services

View details
93
Repo Health
82
Technical
77
Dependency
Built with
C# 84%
Updated 4 days ago
JavaScript
90%
Other

CodeSandbox

Code Editors · Developer Tools

13,650

Instantly ready browser-based IDE that runs full npm dependency resolution and transpilation entirely client-side, with no server needed.

View details
67
Repo Health
76
Technical
62
Dependency
Built with
JavaScript 90%
Updated 3 weeks ago
PHP
78%
Other

Craft CMS

CMS

3,609

A developer-first PHP CMS with clean-slate content modeling, auto-generated GraphQL API, and a four-tier edition system that scales from solo projects to enterprise deployments.

View details
96
Repo Health
83
Technical
62
Dependency
Built with
PHP 78%
JavaScript 14%
Updated 5 days ago
Ruby
39%
AGPL 3.0

DocuSeal

Digital Signiture

18,629

Open source document signing platform with WYSIWYG PDF builder, multi-party workflows, REST API, and full self-hosting via Docker.

View details
87
Repo Health
80
Technical
69
Dependency
Built with
Ruby 39%
Vue 28%
HTML 20%
Updated 1 weeks ago
TypeScript
94%
AGPL 3.0

Element Web

Collaboration · Team Chat

13,518

A polished, self-hostable Matrix client for secure, decentralized messaging and collaboration that puts your organization in full control of its data.

View details
96
Repo Health
83
Technical
65
Dependency
Built with
TypeScript 94%
Updated 5 days ago
Go
65%
AGPL 3.0

Fider

Customer Support · Product Management

4,545

Open-source feedback portal where customers submit, vote on, and track feature requests so product teams build what actually matters.

View details
89
Repo Health
85
Technical
71
Dependency
Built with
Go 65%
TypeScript 28%
Updated 5 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers