An open API service indexing awesome lists of open source software.

https://github.com/daun/modern-sass-glob-importer


https://github.com/daun/modern-sass-glob-importer

Last synced: about 1 month ago
JSON representation

Awesome Lists containing this project

README

          

# Modern Sass Glob Importer

[![npm](https://img.shields.io/npm/v/modern-sass-glob-importer)](https://www.npmjs.com/package/modern-sass-glob-importer)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)

A custom importer for Sass that expands glob patterns.

```scss
@use "components/**/*.scss";
@use "elements/**/*.scss";
```

## Description

While there are a number of Sass glob importers available, none of them currently work with the [modern JS API](https://sass-lang.com/documentation/breaking-changes/legacy-js-api/) or support `@use` statements. This importer only works with the modern API and has no intention of working with the legacy API.

## Features

- Expands `*.glob` patterns to their matching files
- Imports from both `@use` and `@import` statements
- Supports nested imports
- Works with vite, webpack, etc, or standalone

## Installation

```bash
npm install modern-sass-glob-importer
```

## Usage

```js
const sass = require("sass");
const globImporter = require("modern-sass-glob-importer");

// Standalone usage
sass
.compile("path/to/style.scss", {
importers: [globImporter()],
})
.then(function (result) { });
```

## Example

```scss
@use "components/*.scss";
@use "elements/*.scss";
```

## License

MIT