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

@mlnop/webpack-loader-sass-glob-import

v1.0.4

Published

A webpack loader that enables glob imports in SCSS files

Readme

webpack-loader-sass-glob-import

A webpack loader that enables glob imports in SCSS files. This loader allows you to use glob patterns in your SCSS imports, making it easier to import multiple files at once.

Introduction

scss-glob-loader is a webpack loader that allows you to use glob patterns in your Sass or SCSS files. This simplifies the process of importing multiple files, making your stylesheets more modular and easier to maintain.

Installation

npm install --save-dev scss-glob-loader

Configuration

Add the loader to your webpack configuration:

module.exports = {
  module: {
    rules: [
      {
        test: /\.s[ac]ss$/i,
        use: [
          "style-loader",
          "css-loader",
          "sass-loader",
          {
            loader: "scss-glob-loader",
            options: {},
          },
        ],
      },
    ],
  },
};

Features

  • Supports glob patterns in @import, @use, and @include statements
  • Namespace is mandatory when using @use with glob patterns
  • Flexible namespace generation for @use imports
  • Preserves comments and whitespace
  • Supports both .scss and .sass files
  • Provides warning messages for invalid glob paths

Namespace Options

The loader supports three namespace modes:

  1. Default Mode (namespace: true):

    {
      loader: 'scss-glob-loader',
    }

    Generates namespaces based on file paths:

    • File: components/_button.scss → Namespace: components-button
    • File: blocks/header/styles/_nav.scss → Namespace: blocks-header-styles-nav
  2. Wildcard Mode (namespace: '*'):

    {
      loader: 'scss-glob-loader',
      options: {
        namespace: '*'
      }
    }

    Uses * as namespace for all files:

    @use "components/*.scss" as *;
  3. Custom Function (namespace: (filename, index) => string):

    {
      loader: 'scss-glob-loader',
      options: {
        namespace: (filename, index) => {
          // Custom namespace logic
          return `custom-namespace-${index}`;
        }
      }
    }

    Allows you to define your own namespace generation logic.

Usage Examples

Basic Usage

// Import all SCSS files in a directory
@import "components/*.scss";

// Use all SCSS files in a directory with auto-generated namespaces
@use "components/*.scss";

// Include all SCSS files in a directory with meta.load-css
@include meta.load-css("components/*.scss");

Advanced Usage

// Import specific file types
@import "components/**/*.scss";

// Use with wildcard namespace
@use "components/*.scss" as *;

// Use with custom namespace function
@use "components/*.scss";

// Include with meta.load-css
.your-class {
  @include meta.load-css("components/*.scss");
}

Directory Structure Example

styles/
├── components/
│   ├── _button.scss
│   ├── _card.scss
│   └── _nav.scss
├── utils/
│   ├── _variables.scss
│   └── _mixins.scss
└── main.scss
// In main.scss
@use "components/*.scss";
@use "utils/*.scss";

// Will be transformed to:
@use "components/button.scss" as components-button;
@use "components/card.scss" as components-card;
@use "components/nav.scss" as components-nav;
@use "utils/variables.scss" as utils-variables;
@use "utils/mixins.scss" as utils-mixins;

Caveats

  • Globbing only works in a top-level file, not within referenced files
  • The loader processes files in alphabetical order
  • File paths are case-sensitive
  • Only supports * and ** glob patterns
  • Requires webpack 5 or higher

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.