css-loader

css-loader is a webpack loader that interprets @import and url() in CSS. It resolves modules, handles assets, and integrates with style-loader. MIT licensed.

Overview

css-loader is a webpack loader that interprets and resolves @import and url() statements in CSS files. It is part of the webpack ecosystem and is commonly used with style-loader to inject styles into the DOM. The loader resolves CSS imports like JavaScript modules, allowing you to use relative paths and npm packages. It also handles assets referenced in CSS, such as images and fonts, by processing them through webpack's module system. This project is actively maintained on GitHub with over 4,300 stars and is released under the MIT license. It is a fundamental tool for web developers using webpack to bundle stylesheets in modern JavaScript applications.

Highlights

  • Resolves @import and url() in CSS files using webpack's module resolution
  • Supports CSS modules for local scoping of class names
  • Handles assets like images and fonts by emitting them as separate files
  • Works seamlessly with style-loader to inject styles into the DOM
  • Actively maintained with a large community and MIT license

Common use cases

  • Bundling CSS in webpack-based projects for websites and web applications
  • Using CSS Modules to avoid global class name collisions in component-based UIs
  • Managing assets referenced in CSS (e.g., images, fonts) through webpack's build pipeline
  • Building admin dashboards or template sites that require modular CSS handling

View upstream source