The css-loader is a webpack loader that interprets @import and url() in CSS files like JavaScript import/require, resolving them into modules. Current stable version is 7.1.4, released in February 2026, with active development and frequent minor releases. It supports CSS Modules, source maps, and various import/url resolution strategies. Unlike other CSS loaders, it is designed specifically for webpack 5+ and integrates deeply with webpack's module system. Peer dependencies include webpack ^5.27.0 and optional @rspack/core. Key differentiators include fine-grained options for url/import filtering, CSS Modules with named exports, and compatibility with modern CSS features like nesting and @scope.
npm install css-loaderVerified import paths — ran on the pinned version, not inferred.
Shows basic webpack configuration for CSS Modules with latest named export syntax (v7+).
Use import * as styles from './styles.module.css' instead of import styles from './styles.module.css'.
Use { exportLocalsConvention: { camelCase: true } } instead of 'camelCase'.Use a custom filter or set url: false to prevent resolution of absolute paths.
Use url('~module/image.png') instead of url('module/image.png').Upgrade Node.js to version 18.12.0 or later.
Add a rule with css-loader in module.rules: { test: /\.css$/, use: ['style-loader', 'css-loader'] }Run: npm install --save-dev css-loader
Use import * as styles from './styles.module.css'