# esbuild-plugin-sass

> Plugin for esbuild to support SASS styles

Latest version **1.0.1** (published 2022-01-10) · ISC license · 0 weekly downloads

## Install

```sh
npm install esbuild-plugin-sass
pnpm add esbuild-plugin-sass
yarn add esbuild-plugin-sass
bun add esbuild-plugin-sass
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2022-01-10 |
| First published | 2021-01-16 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 12.3 KB |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 45 |
| Author | Nikolai Mavrenkov |
| Maintainers | koluch |
| Keywords | esbuild, plugin, sass |

## Links

- npm: https://www.npmjs.com/package/esbuild-plugin-sass
- Repository: https://github.com/koluch/esbuild-plugin-sass
- Homepage: https://github.com/koluch/esbuild-plugin-sass#readme
- Issues: https://github.com/koluch/esbuild-plugin-sass/issues
- npm.io page: https://npm.io/package/esbuild-plugin-sass

## Dependencies (4)

- [tmp](https://npm.io/package/tmp.md) 0.2.1
- [sass](https://npm.io/package/sass.md) 1.47.0
- [css-tree](https://npm.io/package/css-tree.md) 1.1.3
- [fs-extra](https://npm.io/package/fs-extra.md) 10.0.0

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2022-01-10
- 1.0.0 — 2022-01-09
- 0.7.0 — 2022-01-08
- 0.6.0 — 2021-08-08
- 0.5.2 — 2021-07-10
- 0.5.1 — 2021-06-14
- 0.5.0 — 2021-04-24
- 0.4.1 — 2021-03-24
- 0.4.0 — 2021-03-24
- 0.3.4 — 2021-03-21
- 0.3.3 — 2021-01-25
- 0.3.2 — 2021-01-18
- 0.3.1 — 2021-01-18
- 0.3.0 — 2021-01-18
- 0.2.1 — 2021-01-17
- … 1 more at https://npm.io/package/esbuild-plugin-sass/versions

## README

# esbuild-plugin-sass

![Node.js CI](https://github.com/koluch/esbuild-plugin-sass/workflows/Node.js%20CI/badge.svg)

Plugin for [esbuild](https://esbuild.github.io/) to support Sass style sheets

## Install

```shell
npm i esbuild esbuild-plugin-sass
```

or, using [pnpm](https://pnpm.io/):

```shell
pnpm add esbuild esbuild-plugin-sass
```

## Usage example

Create file `src/test.scss`:

```scss
body {
  &.isRed {
    background: red;
  }
}
```

Create file `src/index.js`:

```js
import "./test.scss";
```

Create file `build.js`:

```js
const esbuild = require("esbuild");
const sassPlugin = require("esbuild-plugin-sass");

esbuild
  .build({
    entryPoints: ["src/index.js"],
    bundle: true,
    outfile: "bundle.js",
    plugins: [sassPlugin()],
  })
  .catch((e) => console.error(e.message));
```

Run:

```console
$ node build.js
```

File named `bundle.css` with following content will be created:

```css
body.isRed {
  background: red;
}
```

# API

Module default-exports a function, which need to be called with or without options object:

```typescript
import sass = require("sass");

interface Options {
  rootDir?: string;
  customSassOptions?: Omit<sass.Options, "file">;
}

export = (options: Options = {}) => Plugin;
```

Supported options:

- `rootDir` - folder to resolve paths against
- `customSassOptions` - options object passed to `sass` [compile](https://sass-lang.com/documentation/js-api/modules#compile) function, except `file` option, which is overriden by plugin for each processed file

---
_Source: https://npm.io/package/esbuild-plugin-sass · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
