npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

namespace-css-module-loader

v0.5.0

Published

Webpack CSS Module loader to namespace all rules with a single hash

Readme

namespace-css-module-loader

npm

Webpack's css-loader implements CSS Modules by giving every .class a unique hash which you then have to bind to your element/complement.

.a { ... }
.b { ... }

output with regular CSS Modules (webpack css-loader):

.dz1R8A {  /* a different hash */ }
.JkxzOD {  /* for each rule */ }

namespace-css-module-loader, as the name suggests, only gives one unique hash (a namespace) to all rules:

.2Jlr3B .a { /* both “wrapped” in the same hash */ }
.2Jlr3B .b { /* giving your rules a single namespace */ }

This hash is available as a single named export: {style} which you only need to include in the parent div:

import {style} from './style.scss';
export default <div className={style}>
  <div class='a'></div>
  <div class='b'></div>
</div>

Install

npm i namespace-css-module-loader

Usage

In your webpack config:

loader: 'css-loader!namespace-css-module-loader'

Use it after pre-processors, it only works on pure CSS

loader: 'css-loader?importLoaders=3!postcss-loader!namespace-css-module-loader!sass-loader'
                                         ...      <-          ^               <-  pre

Options

Provide options to the module as a query string or query object

loader: 'css-loader!namespace-css-module-loader?id=root'
loader: ['css-loader', {
  loader: 'namespace-css-module-loader',
  query: {
    id: 'root'
  }
}]

id (string) (default: 'style')

Change the default named export {style}:

import {root} from './app.scss';
export default <div className={root}></div>

descendant (boolean) (default: true)

Make the rule descendant of the namespace (default)

.a .b {...}
/* => */
.2Jlr3B .a .b {...}

combine (boolean)

Combine the rule with the namespace instead of making it a descendant

.a .b {...}
/* => */
.a.2Jlr3B .b {...}

combine & descendant

Both options can be used together to group the rules:

.a .b {...}
/* => */
.a.2Jlr3B .b, .2Jlr3B .a .b {...}

Issues

Hot Module Replacement

It probably has nothing to do with this module but if HMR isn't working correctly try adding webpack-module-hot-accept to all your JS files.

it hot-reloads only if [you] have a module.hot.accept() call in the JS that require-s the CSS Module. (react-css-modules#51)

related: css-loader#186