code:
[![npm][npm]][npm-url]
[![node][node]][node-url]
[![tests][tests]][tests-url]
[![coverage][cover]][cover-url]
[![discussion][discussion]][discussion-url]
[![size][size]][size-url]

# sass-loader

Loads a Sass/SCSS file and compiles it to CSS.

## Getting Started

To begin, you'll need to install `sass-loader`:

```console
npm install sass-loader sass webpack --save-dev
```

or

```console
yarn add -D sass-loader sass webpack
```

or

```console
pnpm add -D sass-loader sass webpack
```

`sass-loader` requires you to install either [Dart Sass](https://github.com/sass/dart-sass), [Node Sass](https://github.com/sass/node-sass) on your own (more documentation can be found below) or [Sass Embedded](https://github.com/sass/embedded-host-node).

This allows you to control the versions of all your dependencies, and to choose which Sass implementation to use.

> **Note**
>
> We highly recommend using [Dart Sass](https://github.com/sass/dart-sass).

> **Warning**
>
> [Node Sass](https://github.com/sass/node-sass) does not work with [Yarn PnP](https://classic.yarnpkg.com/en/docs/pnp/) feature and doesn't support [@use rule](https://sass-lang.com/documentation/at-rules/use).

> **Warning**
>
> [Sass Embedded](https://github.com/sass/embedded-host-node) is experimental and in `beta`, therefore some features may not work

Chain the `sass-loader` with the [css-loader](https://github.com/webpack-contrib/css-loader) and the [style-loader](https://github.com/webpack-contrib/style-loader) to immediately apply all styles to the DOM or the [mini-css-extract-plugin](https://github.com/webpack-contrib/mini-css-extract-plugin) to extract it into a separate file.

Then add the loader to your Webpack configuration. For example:

**app.js**

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

**style.scss**

```scss
$body-color: red;

body {
  color: $body-color;
}
```

**webpack.config.js**

```js
module.exports = {
  module: {
    rules: [
      {
        test: /\.s[ac]ss$/i,
        use: [
          // Creates `style` nodes from JS strings
          "style-loader",
          // Translates CSS into CommonJS
          "css-loader",
          // Compiles Sass to CSS
          "sass-loader",
        ],
      },
    ],
  },
};
```

Finally run `webpack` via your preferred method.

### The `outputStyle` (old API) and `style` (new API) options in `production` mode

For `production` mode, the `outputStyle` (old API) and `style` (new API) options default to `compressed` unless otherwise specified in `sassOptions`.

### Resolving `import` at-rules

Webpack provides an [advanced mechanism to resolve files](https://webpack.js.org/concepts/module-resolution/).

The `sass-loader` uses Sass's custom importer feature to pass all queries to the Webpack resolving engine.
Thus you can import your Sass modules from `node_modules`.

```scss
@import "bootstrap";
```

Using `~` is deprecated and can be removed from your code (**we recommend it**), but we still support it for historical reasons.
Why can you remove it? The loader will first try to resolve `@import` as a relative path. If it cannot be resolved, then the loader will try to resolve `@import` inside [`node_modules`](https://webpack.js.org/configuration/resolve/#resolvemodules).

Prepending module paths with a `~` tells webpack to search through [`node_modules`](https://webpack.js.org/configuration/resolve/#resolvemodules).

```scss
@import "~bootstrap";
```

It's important to prepend it with only `~`, because `~/` resolves to the home directory.
Webpack needs to distinguish between `bootstrap` and `~bootstrap` because CSS and Sass files have no special syntax for importing relative files.
Writing `@import "style.scss"` is the same as `@import "./style.scss";`

### Problems with `url(...)`

Since Sass implementations don't provide [url rewriting](https://github.com/sass/libsass/issues/532), all linked assets must be relative to the output.

- If you pass the generated CSS on to the `css-loader`, all urls must be relative to the entry-file (e.g. `main.scss`).
- If you're just generating CSS without passing it to the `css-loader`, it must be relative to your web root.

You will be disrupted by this first issue. It is natural to expect relative references to be resolved against the `.sass`/`.scss` file in which they are specified (like in regular `.css` files).

Thankfully there are a two solutions to this problem:

- Add the missing url rewriting using the [resolve-url-loader](https://github.com/bholloway/resolve-url-loader). Place it before `sass-loader` in the loader chain.
- Library authors usually provide a variable to modify the asset path. [bootstrap-sass](https://github.com/twbs/bootstrap-sass) for example has an `$icon-font-path`.

## Options

- **[`implementation`](#implementation)**
- **[`sassOptions`](#sassoptions)**
- **[`sourceMap`](#sourcemap)**
- **[`additionalData`](#additionaldata)**
- **[`webpackImporter`](#webpackimporter)**
- **[`warnRuleAsWarning`](#warnruleaswarning)**

### `implementation`

Type:

```ts
type implementation = object | string;
```

Default: `sass`

The special `implementation` option determines which implementation of Sass to use.

By default the loader resolve the implementation based on your dependencies.
Just add required implementation to `package.json` (`sass` or `node-sass` package) and install dependencies.

Example where the `sass-loader` loader uses the `sass` (`dart-sass`) implementation:

**package.json**

```json
{
  "devDependencies": {
    "sass-loader": "^7.2.0",
    "sass": "^1.22.10"
  }
}
```

Example where the `sass-loader` loader uses the `node-sass` implementation:

**package.json**

```json
{
  "devDependencies": {
    "sass-loader": "^7.2.0",
    "node-sass": "^5.0.0"
  }
}
```

Beware the situation when `node-sass` and `sass` were installed! By default the `sass-loader` prefers `sass`.
In order to avoid this situation you can use the `implementation` option.

The `implementation` options either accepts `sass` (`Dart Sass`) or `node-sass` as a module.

#### `object`

For example, to use Dart Sass, you'd pass:

```js
module.exports = {
  module: {
    rules: [
      {
        test: /\.s[ac]ss$/i,
        use: [
          "style-loader",
          "css-loader",
          {
            loader: "sass-loader",
            options: {
              // Prefer `dart-sass`
              implementation: require("sass"),
            },
          },
        ],
      },
    ],
  },
};
```

#### `string`

For example, to use Dart Sass, you'd pass:

```js
module.exports = {
  module: {
    rules: [
      {
        test: /\.s[ac]ss$/i,
        use: [
          "style-loader",
          "css-loader",
          {
            loader: "sass-loader",
            options: {
              // Prefer `dart-sass`
              implementation: require.resolve("sass"),
            },
          },
        ],
      },
    ],
  },
};
```

### `sassOptions`

Type:

```ts
type sassOptions =
  | import("sass").LegacyOptions<"async">
  | ((
      content: string | Buffer,
      loaderContext: LoaderContext,
      meta: any,
    ) => import("sass").LegacyOptions<"async">);
```

Default: defaults values for Sass implementation

Options for [Dart Sass](http://sass-lang.com/dart-sass) or [Node Sass](https://github.com/sass/node-sass) implementation.

> **Note**
>
> The `charset` option has `true` value by default for `dart-sass`, we strongly discourage change value to `false`, because webpack doesn't support files other than `utf-8`.

> **Note**
>
> The `indentedSyntax` option has `true` value for the `sass` extension.

> **Note**
>
> Options such as `data` and `file` are unavailable and will be ignored.

> ℹ We strongly discourage change `outFile`, `sourceMapContents`, `sourceMapEmbed`, `sourceMapRoot` options because `sass-loader` automatically sets these options when the `sourceMap` option is `true`.

> **Note**
>
> Access to the [loader context](https://webpack.js.org/api/loaders/#the-loader-context) inside the custom importer can be done using the `this.webpackLoaderContext` property.

There is a slight difference between the `sass` (`dart-sass`) and `node-sass` options.

Please consult documentation before using them:

- [Dart Sass documentation](https://sass-lang.com/documentation/js-api/interfaces/Options) for all available `sass` options.
- [Node Sass documentation](https://github.com/sass/node-sass/#options) for all available `node-sass` options.

#### `object`

Use an object for the Sass implementation setup.

**webpack.config.js**

```js
module.exports = {
  module: {
    rules: [
      {
        test: /\.s[ac]ss$/i,
        use: [
          "style-loader",
          "css-loader",
          {
            loader: "sass-loader",
            options: {
              sassOptions: {
                indentWidth: 4,
                includePaths: ["absolute/path/a", "absolute/path/b"],
              },
            },
          },
        ],
      },
    ],
  },
};
```

#### `function`

Allows to setup the Sass implementation by setting different options based on the loader context.

```js
module.exports = {
  module: {
    rules: [
      {
        test: /\.s[ac]ss$/i,
        use: [
          "style-loader",
          "css-loader",
          {
            loader: "sass-loader",
            options: {
              sassOptions: (content, loaderContext) => {
                // More information about available properties https://webpack.js.org/api/loaders/
                const { resourcePath, rootContext } = loaderContext;
                const relativePath = path.relative(rootContext, resourcePath);

                if (relativePath === "styles/foo.scss") {
                  return {
                    includePaths: ["absolute/path/c", "absolute/path/d"],
                  };
                }

                return {
                  includePaths: ["absolute/path/a", "absolute/path/b"],
                };
              },
            },
          },
        ],
      },
    ],
  },
};
```

### `sourceMap`

Type:

```ts
type sourceMap = boolean;
```

Default: depends on the `compiler.devtool` value

Enables/Disables generation of source maps.

By default generation of source maps depends on the [`devtool`](https://webpack.js.org/configuration/devtool/) option.
All values enable source map generation except `eval` and `false` value.

> ℹ If a `true` the `sourceMap`, `sourceMapRoot`, `sourceMapEmbed`, `sourceMapContents` and `omitSourceMapUrl` from `sassOptions` will be ignored.

**webpack.config.js**

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

> ℹ In some rare cases `node-sass` can output invalid source maps (it is a `node-sass` bug).

> > In order to avoid this, you can try to update `node-sass` to latest version or you can try to set within `sassOptions` the `outputStyle` option to `compressed`.

**webpack.config.js**

```js
module.exports = {
  module: {
    rules: [
      {
        test: /\.s[ac]ss$/i,
        use: [
          "style-loader",
          "css-loader",
          {
            loader: "sass-loader",
            options: {
              sourceMap: true,
              sassOptions: {
                outputStyle: "compressed",
              },
            },
          },
        ],
      },
    ],
  },
};
```

### `additionalData`

Type:

```ts
type additionalData =
  | string
  | ((content: string | Buffer, loaderContext: LoaderContext) => string);
```

Default: `undefined`

Prepends `Sass`/`SCSS` code before the actual entry file.
In this case, the `sass-loader` will not override the `data` option but just **prepend** the entry's content.

This is especially useful when some of your Sass variables depend on the environment:

#### `string`

```js
module.exports = {
  module: {
    rules: [
      {
        test: /\.s[ac]ss$/i,
        use: [
          "style-loader",
          "css-loader",
          {
            loader: "sass-loader",
            options: {
              additionalData: "$env: " + process.env.NODE_ENV + ";",
            },
          },
        ],
      },
    ],
  },
};
```

#### `function`

##### Sync

```js
module.exports = {
  module: {
    rules: [
      {
        test: /\.s[ac]ss$/i,
        use: [
          "style-loader",
          "css-loader",
          {
            loader: "sass-loader",
            options: {
              additionalData: (content, loaderContext) => {
                // More information about available properties https://webpack.js.org/api/loaders/
                const { resourcePath, rootContext } = loaderContext;
                const relativePath = path.relative(rootContext, resourcePath);

                if (relativePath === "styles/foo.scss") {
                  return "$value: 100px;" + content;
                }

                return "$value: 200px;" + content;
              },
            },
          },
        ],
      },
    ],
  },
};
```

##### Async

```js
module.exports = {
  module: {
    rules: [
      {
        test: /\.s[ac]ss$/i,
        use: [
          "style-loader",
          "css-loader",
          {
            loader: "sass-loader",
            options: {
              additionalData: async (content, loaderContext) => {
                // More information about available properties https://webpack.js.org/api/loaders/
                const { resourcePath, rootContext } = loaderContext;
                const relativePath = path.relative(rootContext, resourcePath);

                if (relativePath === "styles/foo.scss") {
                  return "$value: 100px;" + content;
                }

                return "$value: 200px;" + content;
              },
            },
          },
        ],
      },
    ],
  },
};
```

### `webpackImporter`

Type:

```ts
type webpackImporter = boolean;
```

Default: `true`

Enables/Disables the default Webpack importer.

This can improve performance in some cases. Use it with caution because aliases and `@import` at-rules starting with `~` will not work.
You can pass own `importer` to solve this (see [`importer docs`](https://github.com/sass/node-sass#importer--v200---experimental)).

**webpack.config.js**

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

### `warnRuleAsWarning`

Type:

```ts
type warnRuleAsWarning = boolean;
```

Default: `true`

Treats the `@warn` rule as a webpack warning.

**style.scss**

```scss
$known-prefixes: webkit, moz, ms, o;

@mixin prefix($property, $value, $prefixes) {
  @each $prefix in $prefixes {
    @if not index($known-prefixes, $prefix) {
      @warn "Unknown prefix #{$prefix}.";
    }

    -#{$prefix}-#{$property}: $value;
  }
  #{$property}: $value;
}

.tilt {
  // Oops, we typo'd "webkit" as "wekbit"!
  @include prefix(transform, rotate(15deg), wekbit ms);
}
```

The presented code will throw webpack warning instead logging.

To ignore unnecessary warnings you can use the [ignoreWarnings](https://webpack.js.org/configuration/other-options/#ignorewarnings) option.

**webpack.config.js**

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

### `api`

Type:

```ts
type api = "legacy" | "modern" | "modern-compiler";
```

Default: `"legacy"`

Allows you to switch between `legacy` and `modern` API. You can find more information [here](https://sass-lang.com/documentation/js-api). The `modern-compiler` option enables the modern API with support for [Shared Resources](https://github.com/sass/sass/blob/main/accepted/shared-resources.d.ts.md).

> **Note**
>
> Using `modern-compiler` and `sass-embedded` together significantly improve performance and decrease built time. We strongly recommend their use. We will enable them by default in a future major release.

> **Warning**
>
> The sass options are different for `modern` and `old` APIs. Please look at [docs](https://sass-lang.com/documentation/js-api) how to migrate on new options.

**webpack.config.js**

```js
module.exports = {
  module: {
    rules: [
      {
        test: /\.s[ac]ss$/i,
        use: [
          "style-loader",
          "css-loader",
          {
            loader: "sass-loader",
            options: {
              api: "modern",
              sassOptions: {
                // Your sass options
              },
            },
          },
        ],
      },
    ],
  },
};
```

## How to enable `@debug` output

Defaults, the output of `@debug` messages is disabled.
To enable it, add to **webpack.config.js** following:

```js
module.exports = {
  stats: {
    loggingDebug: ["sass-loader"],
  },
  // ...
};
```

## Examples

### Extracts CSS into separate files

For production builds it's recommended to extract the CSS from your bundle being able to use parallel loading of CSS/JS resources later on.

There are four possibilities to extract a style sheet from the bundle:

#### 1. [mini-css-extract-plugin](https://github.com/webpack-contrib/mini-css-extract-plugin)

**webpack.config.js**

```js
const MiniCssExtractPlugin = require("mini-css-extract-plugin");

module.exports = {
  module: {
    rules: [
      {
        test: /\.s[ac]ss$/i,
        use: [
          // fallback to style-loader in development
          process.env.NODE_ENV !== "production"
            ? "style-loader"
            : MiniCssExtractPlugin.loader,
          "css-loader",
          "sass-loader",
        ],
      },
    ],
  },
  plugins: [
    new MiniCssExtractPlugin({
      // Options similar to the same options in webpackOptions.output
      // both options are optional
      filename: "[name].css",
      chunkFilename: "[id].css",
    }),
  ],
};
```

#### 2. [Asset Modules](https://webpack.js.org/guides/asset-modules/)

**webpack.config.js**

```js
module.exports = {
  entry: [__dirname + "/src/scss/app.scss"],
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        use: [],
      },
      {
        test: /\.scss$/,
        exclude: /node_modules/,
        type: "asset/resource",
        generator: {
          filename: "bundle.css",
        },
        use: ["sass-loader"],
      },
    ],
  },
};
```

#### 3. [extract-loader](https://github.com/peerigon/extract-loader) (simpler, but specialized on the css-loader's output)

#### 4. [file-loader](https://github.com/webpack-contrib/file-loader) (deprecated--should only be used in Webpack v4)

**webpack.config.js**

```js
module.exports = {
  entry: [__dirname + "/src/scss/app.scss"],
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        use: [],
      },
      {
        test: /\.scss$/,
        exclude: /node_modules/,
        use: [
          {
            loader: "file-loader",
            options: { outputPath: "css/", name: "[name].min.css" },
          },
          "sass-loader",
        ],
      },
    ],
  },
};
```

(source: https://stackoverflow.com/a/60029923/2969615)

### Source maps

Enables/Disables generation of source maps.

To enable CSS source maps, you'll need to pass the `sourceMap` option to the `sass-loader` _and_ the css-loader.

**webpack.config.js**

```javascript
module.exports = {
  devtool: "source-map", // any "source-map"-like devtool is possible
  module: {
    rules: [
      {
        test: /\.s[ac]ss$/i,
        use: [
          "style-loader",
          {
            loader: "css-loader",
            options: {
              sourceMap: true,
            },
          },
          {
            loader: "sass-loader",
            options: {
              sourceMap: true,
            },
          },
        ],
      },
    ],
  },
};
```

If you want to edit the original Sass files inside Chrome, [there's a good blog post](https://medium.com/@toolmantim/getting-started-with-css-sourcemaps-and-in-browser-sass-editing-b4daab987fb0). Checkout [test/sourceMap](https://github.com/webpack-contrib/sass-loader/tree/master/test) for a running example.

## Contributing

Please take a moment to read our contributing guidelines if you haven't yet done so.

[CONTRIBUTING](./.github/CONTRIBUTING.md)

## License

[MIT](./LICENSE)

[npm]: https://img.shields.io/npm/v/sass-loader.svg
[npm-url]: https://npmjs.com/package/sass-loader
[node]: https://img.shields.io/node/v/sass-loader.svg
[node-url]: https://nodejs.org
[tests]: https://github.com/webpack-contrib/sass-loader/workflows/sass-loader/badge.svg
[tests-url]: https://github.com/webpack-contrib/sass-loader/actions
[cover]: https://codecov.io/gh/webpack-contrib/sass-loader/branch/master/graph/badge.svg
[cover-url]: https://codecov.io/gh/webpack-contrib/sass-loader
[discussion]: https://img.shields.io/github/discussions/webpack/webpack
[discussion-url]: https://github.com/webpack/webpack/discussions
[size]: https://packagephobia.now.sh/badge?p=sass-loader
[size-url]: https://packagephobia.now.sh/result?p=sass-loader


code:
"use strict";

const loader = require("./index");
module.exports = loader.default;

license: mit


code:
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _url = _interopRequireDefault(require("url"));
var _path = _interopRequireDefault(require("path"));
var _options = _interopRequireDefault(require("./options.json"));
var _utils = require("./utils");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
 * The sass-loader makes node-sass and dart-sass available to webpack modules.
 *
 * @this {object}
 * @param {string} content
 */
async function loader(content) {
  const options = this.getOptions(_options.default);
  const callback = this.async();
  let implementation;
  try {
    implementation = (0, _utils.getSassImplementation)(this, options.implementation);
  } catch (error) {
    callback(error);
    return;
  }
  const useSourceMap = typeof options.sourceMap === "boolean" ? options.sourceMap : this.sourceMap;
  const sassOptions = await (0, _utils.getSassOptions)(this, options, content, implementation, useSourceMap);
  const shouldUseWebpackImporter = typeof options.webpackImporter === "boolean" ? options.webpackImporter : true;
  if (shouldUseWebpackImporter) {
    const isModernAPI = options.api === "modern" || options.api === "modern-compiler";
    if (!isModernAPI) {
      const {
        includePaths
      } = sassOptions;
      sassOptions.importer.push((0, _utils.getWebpackImporter)(this, implementation, includePaths));
    } else {
      sassOptions.importers.push(
      // No need to pass `loadPaths`, because modern API handle them itself
      (0, _utils.getModernWebpackImporter)(this, implementation, []));
    }
  }
  let compile;
  try {
    compile = (0, _utils.getCompileFn)(this, implementation, options);
  } catch (error) {
    callback(error);
    return;
  }
  let result;
  try {
    result = await compile(sassOptions);
  } catch (error) {
    // There are situations when the `file`/`span.url` property do not exist
    // Modern API
    if (error.span && typeof error.span.url !== "undefined") {
      this.addDependency(_url.default.fileURLToPath(error.span.url));
    }
    // Legacy API
    else if (typeof error.file !== "undefined") {
      // `node-sass` returns POSIX paths
      this.addDependency(_path.default.normalize(error.file));
    }
    callback((0, _utils.errorFactory)(error));
    return;
  }
  let map =
  // Modern API, then legacy API
  result.sourceMap ? result.sourceMap : result.map ? JSON.parse(result.map) : null;

  // Modify source paths only for webpack, otherwise we do nothing
  if (map && useSourceMap) {
    map = (0, _utils.normalizeSourceMap)(map, this.rootContext);
  }

  // Modern API
  if (typeof result.loadedUrls !== "undefined") {
    result.loadedUrls.filter(loadedUrl => loadedUrl.protocol === "file:").forEach(includedFile => {
      const normalizedIncludedFile = _url.default.fileURLToPath(includedFile);

      // Custom `importer` can return only `contents` so includedFile will be relative
      if (_path.default.isAbsolute(normalizedIncludedFile)) {
        this.addDependency(normalizedIncludedFile);
      }
    });
  }
  // Legacy API
  else if (typeof result.stats !== "undefined" && typeof result.stats.includedFiles !== "undefined") {
    result.stats.includedFiles.forEach(includedFile => {
      const normalizedIncludedFile = _path.default.normalize(includedFile);

      // Custom `importer` can return only `contents` so includedFile will be relative
      if (_path.default.isAbsolute(normalizedIncludedFile)) {
        this.addDependency(normalizedIncludedFile);
      }
    });
  }
  callback(null, result.css.toString(), map);
}
var _default = exports.default = loader;


title: Sass Loader options

type: object

description: The implementation of the sass to be used.

type: string

description: Switch between old and modern API for `sass` (`Dart Sass`) and `Sass Embedded` implementations.

enum: legacy modern modern-compiler

description: Options for `node-sass` or `sass` (`Dart Sass`) implementation.

instanceof: Function

description: Prepends/Appends `Sass`/`SCSS` code before the actual entry file.

description: Enables/Disables generation of source maps.

type: boolean

description: Enables/Disables default `webpack` importer.

description: Treats the '@warn' rule as a webpack warning.


code:
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.errorFactory = errorFactory;
exports.getCompileFn = getCompileFn;
exports.getModernWebpackImporter = getModernWebpackImporter;
exports.getSassImplementation = getSassImplementation;
exports.getSassOptions = getSassOptions;
exports.getWebpackImporter = getWebpackImporter;
exports.getWebpackResolver = getWebpackResolver;
exports.normalizeSourceMap = normalizeSourceMap;
var _url = _interopRequireDefault(require("url"));
var _path = _interopRequireDefault(require("path"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function getDefaultSassImplementation() {
  let sassImplPkg = "sass";
  try {
    require.resolve("sass");
  } catch (ignoreError) {
    try {
      require.resolve("node-sass");
      sassImplPkg = "node-sass";
    } catch (_ignoreError) {
      try {
        require.resolve("sass-embedded");
        sassImplPkg = "sass-embedded";
      } catch (__ignoreError) {
        sassImplPkg = "sass";
      }
    }
  }

  // eslint-disable-next-line import/no-dynamic-require, global-require
  return require(sassImplPkg);
}

/**
 * This function is not Webpack-specific and can be used by tools wishing to mimic `sass-loader`'s behaviour, so its signature should not be changed.
 */
function getSassImplementation(loaderContext, implementation) {
  let resolvedImplementation = implementation;
  if (!resolvedImplementation) {
    resolvedImplementation = getDefaultSassImplementation();
  }
  if (typeof resolvedImplementation === "string") {
    // eslint-disable-next-line import/no-dynamic-require, global-require
    resolvedImplementation = require(resolvedImplementation);
  }
  const {
    info
  } = resolvedImplementation;
  if (!info) {
    throw new Error("Unknown Sass implementation.");
  }
  const infoParts = info.split("\t");
  if (infoParts.length < 2) {
    throw new Error(`Unknown Sass implementation "${info}".`);
  }
  const [implementationName] = infoParts;
  if (implementationName === "dart-sass") {
    // eslint-disable-next-line consistent-return
    return resolvedImplementation;
  } else if (implementationName === "node-sass") {
    // eslint-disable-next-line consistent-return
    return resolvedImplementation;
  } else if (implementationName === "sass-embedded") {
    // eslint-disable-next-line consistent-return
    return resolvedImplementation;
  }
  throw new Error(`Unknown Sass implementation "${implementationName}".`);
}

/**
 * @param {any} loaderContext
 * @returns {boolean}
 */
function isProductionLikeMode(loaderContext) {
  return loaderContext.mode === "production" || !loaderContext.mode;
}
function proxyCustomImporters(importers, loaderContext) {
  return [].concat(importers).map(importer => function proxyImporter(...args) {
    const self = {
      ...this,
      webpackLoaderContext: loaderContext
    };
    return importer.apply(self, args);
  });
}

/**
 * Derives the sass options from the loader context and normalizes its values with sane defaults.
 *
 * @param {object} loaderContext
 * @param {object} loaderOptions
 * @param {string} content
 * @param {object} implementation
 * @param {boolean} useSourceMap
 * @returns {Object}
 */
async function getSassOptions(loaderContext, loaderOptions, content, implementation, useSourceMap) {
  const options = loaderOptions.sassOptions ? typeof loaderOptions.sassOptions === "function" ? loaderOptions.sassOptions(loaderContext) || {} : loaderOptions.sassOptions : {};
  const sassOptions = {
    ...options,
    data: loaderOptions.additionalData ? typeof loaderOptions.additionalData === "function" ? await loaderOptions.additionalData(content, loaderContext) : `${loaderOptions.additionalData}\n${content}` : content
  };
  if (!sassOptions.logger) {
    const needEmitWarning = loaderOptions.warnRuleAsWarning !== false;
    const logger = loaderContext.getLogger("sass-loader");
    const formatSpan = span => `Warning on line ${span.start.line}, column ${span.start.column} of ${span.url || "-"}:${span.start.line}:${span.start.column}:\n`;
    const formatDebugSpan = span => `[debug:${span.start.line}:${span.start.column}] `;
    sassOptions.logger = {
      debug(message, loggerOptions) {
        let builtMessage = "";
        if (loggerOptions.span) {
          builtMessage = formatDebugSpan(loggerOptions.span);
        }
        builtMessage += message;
        logger.debug(builtMessage);
      },
      warn(message, loggerOptions) {
        let builtMessage = "";
        if (loggerOptions.deprecation) {
          builtMessage += "Deprecation ";
        }
        if (loggerOptions.span) {
          builtMessage += formatSpan(loggerOptions.span);
        }
        builtMessage += message;
        if (loggerOptions.span && loggerOptions.span.context) {
          builtMessage += `\n\n${loggerOptions.span.start.line} | ${loggerOptions.span.context}`;
        }
        if (loggerOptions.stack && loggerOptions.stack !== "null") {
          builtMessage += `\n\n${loggerOptions.stack}`;
        }
        if (needEmitWarning) {
          const warning = new Error(builtMessage);
          warning.name = "SassWarning";
          warning.stack = null;
          loaderContext.emitWarning(warning);
        } else {
          logger.warn(builtMessage);
        }
      }
    };
  }
  const isModernAPI = loaderOptions.api === "modern" || loaderOptions.api === "modern-compiler";
  const {
    resourcePath
  } = loaderContext;
  if (isModernAPI) {
    sassOptions.url = _url.default.pathToFileURL(resourcePath);

    // opt.outputStyle
    if (!sassOptions.style && isProductionLikeMode(loaderContext)) {
      sassOptions.style = "compressed";
    }
    if (useSourceMap) {
      sassOptions.sourceMap = true;
    }

    // If we are compiling sass and indentedSyntax isn't set, automatically set it.
    if (typeof sassOptions.syntax === "undefined") {
      const ext = _path.default.extname(resourcePath);
      if (ext && ext.toLowerCase() === ".scss") {
        sassOptions.syntax = "scss";
      } else if (ext && ext.toLowerCase() === ".sass") {
        sassOptions.syntax = "indented";
      } else if (ext && ext.toLowerCase() === ".css") {
        sassOptions.syntax = "css";
      }
    }
    sassOptions.loadPaths = [].concat(
    // We use `loadPaths` in context for resolver, so it should be always absolute
    (sassOptions.loadPaths ? sassOptions.loadPaths.slice() : []).map(includePath => _path.default.isAbsolute(includePath) ? includePath : _path.default.join(process.cwd(), includePath))).concat(process.env.SASS_PATH ? process.env.SASS_PATH.split(process.platform === "win32" ? ";" : ":") : []);
    sassOptions.importers = sassOptions.importers ? Array.isArray(sassOptions.importers) ? sassOptions.importers.slice() : [sassOptions.importers] : [];
  } else {
    sassOptions.file = resourcePath;

    // opt.outputStyle
    if (!sassOptions.outputStyle && isProductionLikeMode(loaderContext)) {
      sassOptions.outputStyle = "compressed";
    }
    if (useSourceMap) {
      // Deliberately overriding the sourceMap option here.
      // node-sass won't produce source maps if the data option is used and options.sourceMap is not a string.
      // In case it is a string, options.sourceMap should be a path where the source map is written.
      // But since we're using the data option, the source map will not actually be written, but
      // all paths in sourceMap.sources will be relative to that path.
      // Pretty complicated... :(
      sassOptions.sourceMap = true;
      sassOptions.outFile = _path.default.join(loaderContext.rootContext, "style.css.map");
      sassOptions.sourceMapContents = true;
      sassOptions.omitSourceMapUrl = true;
      sassOptions.sourceMapEmbed = false;
    }
    const ext = _path.default.extname(resourcePath);

    // If we are compiling sass and indentedSyntax isn't set, automatically set it.
    if (ext && ext.toLowerCase() === ".sass" && typeof sassOptions.indentedSyntax === "undefined") {
      sassOptions.indentedSyntax = true;
    } else {
      sassOptions.indentedSyntax = Boolean(sassOptions.indentedSyntax);
    }

    // Allow passing custom importers to `sass`/`node-sass`. Accepts `Function` or an array of `Function`s.
    sassOptions.importer = sassOptions.importer ? proxyCustomImporters(Array.isArray(sassOptions.importer) ? sassOptions.importer.slice() : [sassOptions.importer], loaderContext) : [];

    // Regression on the `sass-embedded` side
    if (loaderOptions.webpackImporter === false && sassOptions.importer.length === 0) {
      // eslint-disable-next-line no-undefined
      sassOptions.importer = undefined;
    }
    sassOptions.includePaths = [].concat(process.cwd()).concat(
    // We use `includePaths` in context for resolver, so it should be always absolute
    (sassOptions.includePaths ? sassOptions.includePaths.slice() : []).map(includePath => _path.default.isAbsolute(includePath) ? includePath : _path.default.join(process.cwd(), includePath))).concat(process.env.SASS_PATH ? process.env.SASS_PATH.split(process.platform === "win32" ? ";" : ":") : []);
    if (typeof sassOptions.charset === "undefined") {
      sassOptions.charset = true;
    }
  }
  return sassOptions;
}
const MODULE_REQUEST_REGEX = /^[^?]*~/;

// Examples:
// - ~package
// - ~package/
// - ~@org
// - ~@org/
// - ~@org/package
// - ~@org/package/
const IS_MODULE_IMPORT = /^~([^/]+|[^/]+\/|@[^/]+[/][^/]+|@[^/]+\/?|@[^/]+[/][^/]+\/)$/;
const IS_PKG_SCHEME = /^pkg:/i;

/**
 * When `sass`/`node-sass` tries to resolve an import, it uses a special algorithm.
 * Since the `sass-loader` uses webpack to resolve the modules, we need to simulate that algorithm.
 * This function returns an array of import paths to try.
 * The last entry in the array is always the original url to enable straight-forward webpack.config aliases.
 *
 * We don't need emulate `dart-sass` "It's not clear which file to import." errors (when "file.ext" and "_file.ext" files are present simultaneously in the same directory).
 * This reduces performance and `dart-sass` always do it on own side.
 *
 * @param {string} url
 * @param {boolean} forWebpackResolver
 * @param {boolean} fromImport
 * @returns {Array<string>}
 */
function getPossibleRequests(
// eslint-disable-next-line no-shadow
url, forWebpackResolver = false, fromImport = false) {
  let request = url;

  // In case there is module request, send this to webpack resolver
  if (forWebpackResolver) {
    if (MODULE_REQUEST_REGEX.test(url)) {
      request = request.replace(MODULE_REQUEST_REGEX, "");
    }
    if (IS_PKG_SCHEME.test(url)) {
      request = `${request.slice(4)}`;
      return [...new Set([request, url])];
    }
    if (IS_MODULE_IMPORT.test(url) || IS_PKG_SCHEME.test(url)) {
      request = request[request.length - 1] === "/" ? request : `${request}/`;
      return [...new Set([request, url])];
    }
  }

  // Keep in mind: ext can also be something like '.datepicker' when the true extension is omitted and the filename contains a dot.
  // @see https://github.com/webpack-contrib/sass-loader/issues/167
  const extension = _path.default.extname(request).toLowerCase();

  // Because @import is also defined in CSS, Sass needs a way of compiling plain CSS @imports without trying to import the files at compile time.
  // To accomplish this, and to ensure SCSS is as much of a superset of CSS as possible, Sass will compile any @imports with the following characteristics to plain CSS imports:
  //  - imports where the URL ends with .css.
  //  - imports where the URL begins http:// or https://.
  //  - imports where the URL is written as a url().
  //  - imports that have media queries.
  //
  // The `node-sass` package sends `@import` ending on `.css` to importer, it is bug, so we skip resolve
  if (extension === ".css") {
    return [];
  }
  const dirname = _path.default.dirname(request);
  const normalizedDirname = dirname === "." ? "" : `${dirname}/`;
  const basename = _path.default.basename(request);
  const basenameWithoutExtension = _path.default.basename(request, extension);
  return [...new Set([].concat(fromImport ? [`${normalizedDirname}_${basenameWithoutExtension}.import${extension}`, `${normalizedDirname}${basenameWithoutExtension}.import${extension}`] : []).concat([`${normalizedDirname}_${basename}`, `${normalizedDirname}${basename}`]).concat(forWebpackResolver ? [url] : []))];
}
function promiseResolve(callbackResolve) {
  return (context, request) => new Promise((resolve, reject) => {
    callbackResolve(context, request, (error, result) => {
      if (error) {
        reject(error);
      } else {
        resolve(result);
      }
    });
  });
}
async function startResolving(resolutionMap) {
  if (resolutionMap.length === 0) {
    return Promise.reject();
  }
  const [{
    possibleRequests
  }] = resolutionMap;
  if (possibleRequests.length === 0) {
    return Promise.reject();
  }
  const [{
    resolve,
    context
  }] = resolutionMap;
  try {
    return await resolve(context, possibleRequests[0]);
  } catch (_ignoreError) {
    const [, ...tailResult] = possibleRequests;
    if (tailResult.length === 0) {
      const [, ...tailResolutionMap] = resolutionMap;
      return startResolving(tailResolutionMap);
    }

    // eslint-disable-next-line no-param-reassign
    resolutionMap[0].possibleRequests = tailResult;
    return startResolving(resolutionMap);
  }
}
const IS_SPECIAL_MODULE_IMPORT = /^~[^/]+$/;
// `[drive_letter]:\` + `\\[server]\[sharename]\`
const IS_NATIVE_WIN32_PATH = /^[a-z]:[/\\]|^\\\\/i;

/**
 * @public
 * Create the resolve function used in the custom Sass importer.
 *
 * Can be used by external tools to mimic how `sass-loader` works, for example
 * in a Jest transform. Such usages will want to wrap `resolve.create` from
 * [`enhanced-resolve`]{@link https://github.com/webpack/enhanced-resolve} to
 * pass as the `resolverFactory` argument.
 *
 * @param {Function} resolverFactory - A factory function for creating a Webpack
 *   resolver.
 * @param {Object} implementation - The imported Sass implementation, both
 *   `sass` (Dart Sass) and `node-sass` are supported.
 * @param {string[]} [includePaths] - The list of include paths passed to Sass.
 *
 * @throws If a compatible Sass implementation cannot be found.
 */
function getWebpackResolver(resolverFactory, implementation, includePaths = []) {
  const isModernSass = implementation && (implementation.info.includes("dart-sass") || implementation.info.includes("sass-embedded"));
  // We only have one difference with the built-in sass resolution logic and out resolution logic:
  // First, we look at the files starting with `_`, then without `_` (i.e. `_name.sass`, `_name.scss`, `_name.css`, `name.sass`, `name.scss`, `name.css`),
  // although `sass` look together by extensions (i.e. `_name.sass`/`name.sass`/`_name.scss`/`name.scss`/`_name.css`/`name.css`).
  // It shouldn't be a problem because `sass` throw errors:
  // - on having `_name.sass` and `name.sass` (extension can be `sass`, `scss` or `css`) in the same directory
  // - on having `_name.sass` and `_name.scss` in the same directory
  //
  // Also `sass` prefer `sass`/`scss` over `css`.
  const sassModuleResolve = promiseResolve(resolverFactory({
    alias: [],
    aliasFields: [],
    conditionNames: [],
    descriptionFiles: [],
    extensions: [".sass", ".scss", ".css"],
    exportsFields: [],
    mainFields: [],
    mainFiles: ["_index", "index"],
    modules: [],
    restrictions: [/\.((sa|sc|c)ss)$/i],
    preferRelative: true
  }));
  const sassImportResolve = promiseResolve(resolverFactory({
    alias: [],
    aliasFields: [],
    conditionNames: [],
    descriptionFiles: [],
    extensions: [".sass", ".scss", ".css"],
    exportsFields: [],
    mainFields: [],
    mainFiles: ["_index.import", "_index", "index.import", "index"],
    modules: [],
    restrictions: [/\.((sa|sc|c)ss)$/i],
    preferRelative: true
  }));
  const webpackModuleResolve = promiseResolve(resolverFactory({
    dependencyType: "sass",
    conditionNames: ["sass", "style", "..."],
    mainFields: ["sass", "style", "main", "..."],
    mainFiles: ["_index", "index", "..."],
    extensions: [".sass", ".scss", ".css"],
    restrictions: [/\.((sa|sc|c)ss)$/i],
    preferRelative: true
  }));
  const webpackImportResolve = promiseResolve(resolverFactory({
    dependencyType: "sass",
    conditionNames: ["sass", "style", "..."],
    mainFields: ["sass", "style", "main", "..."],
    mainFiles: ["_index.import", "_index", "index.import", "index", "..."],
    extensions: [".sass", ".scss", ".css"],
    restrictions: [/\.((sa|sc|c)ss)$/i],
    preferRelative: true
  }));
  return (context, request, fromImport) => {
    // See https://github.com/webpack/webpack/issues/12340
    // Because `node-sass` calls our importer before `1. Filesystem imports relative to the base file.`
    // custom importer may not return `{ file: '/path/to/name.ext' }` and therefore our `context` will be relative
    if (!isModernSass && !_path.default.isAbsolute(context)) {
      return Promise.reject();
    }
    const originalRequest = request;
    const isFileScheme = originalRequest.slice(0, 5).toLowerCase() === "file:";
    if (isFileScheme) {
      try {
        // eslint-disable-next-line no-param-reassign
        request = _url.default.fileURLToPath(originalRequest);
      } catch (ignoreError) {
        // eslint-disable-next-line no-param-reassign
        request = request.slice(7);
      }
    }
    let resolutionMap = [];
    const needEmulateSassResolver =
    // `sass` doesn't support module import
    !IS_SPECIAL_MODULE_IMPORT.test(request) &&
    // don't handle `pkg:` scheme
    !IS_PKG_SCHEME.test(request) &&
    // We need improve absolute paths handling.
    // Absolute paths should be resolved:
    // - Server-relative URLs - `<context>/path/to/file.ext` (where `<context>` is root context)
    // - Absolute path - `/full/path/to/file.ext` or `C:\\full\path\to\file.ext`
    !isFileScheme && !originalRequest.startsWith("/") && !IS_NATIVE_WIN32_PATH.test(originalRequest);
    if (includePaths.length > 0 && needEmulateSassResolver) {
      // The order of import precedence is as follows:
      //
      // 1. Filesystem imports relative to the base file.
      // 2. Custom importer imports.
      // 3. Filesystem imports relative to the working directory.
      // 4. Filesystem imports relative to an `includePaths` path.
      // 5. Filesystem imports relative to a `SASS_PATH` path.
      //
      // `sass` run custom importers before `3`, `4` and `5` points, we need to emulate this behavior to avoid wrong resolution.
      const sassPossibleRequests = getPossibleRequests(request, false, fromImport);

      // `node-sass` calls our importer before `1. Filesystem imports relative to the base file.`, so we need emulate this too
      if (!isModernSass) {
        resolutionMap = resolutionMap.concat({
          resolve: fromImport ? sassImportResolve : sassModuleResolve,
          context: _path.default.dirname(context),
          possibleRequests: sassPossibleRequests
        });
      }
      resolutionMap = resolutionMap.concat(
      // eslint-disable-next-line no-shadow
      includePaths.map(context => {
        return {
          resolve: fromImport ? sassImportResolve : sassModuleResolve,
          context,
          possibleRequests: sassPossibleRequests
        };
      }));
    }
    const webpackPossibleRequests = getPossibleRequests(request, true, fromImport);
    resolutionMap = resolutionMap.concat({
      resolve: fromImport ? webpackImportResolve : webpackModuleResolve,
      context: _path.default.dirname(context),
      possibleRequests: webpackPossibleRequests
    });
    return startResolving(resolutionMap);
  };
}
const MATCH_CSS = /\.css$/i;
function getModernWebpackImporter(loaderContext, implementation, loadPaths) {
  const resolve = getWebpackResolver(loaderContext.getResolve, implementation, loadPaths);
  return {
    async canonicalize(originalUrl, context) {
      const {
        fromImport
      } = context;
      const prev = context.containingUrl ? _url.default.fileURLToPath(context.containingUrl.toString()) : loaderContext.resourcePath;
      let result;
      try {
        result = await resolve(prev, originalUrl, fromImport);
      } catch (err) {
        // If no stylesheets are found, the importer should return null.
        return null;
      }
      loaderContext.addDependency(_path.default.normalize(result));
      return _url.default.pathToFileURL(result);
    },
    async load(canonicalUrl) {
      const ext = _path.default.extname(canonicalUrl.pathname);
      let syntax;
      if (ext && ext.toLowerCase() === ".scss") {
        syntax = "scss";
      } else if (ext && ext.toLowerCase() === ".sass") {
        syntax = "indented";
      } else if (ext && ext.toLowerCase() === ".css") {
        syntax = "css";
      } else {
        // Fallback to default value
        syntax = "scss";
      }
      try {
        const contents = await new Promise((resolve, reject) => {
          // Old version of `enhanced-resolve` supports only path as a string
          // TODO simplify in the next major release and pass URL
          const canonicalPath = _url.default.fileURLToPath(canonicalUrl);
          loaderContext.fs.readFile(canonicalPath, "utf8", (err, content) => {
            if (err) {
              reject(err);
              return;
            }
            resolve(content);
          });
        });
        return {
          contents,
          syntax
        };
      } catch (err) {
        return null;
      }
    }
  };
}
function getWebpackImporter(loaderContext, implementation, includePaths) {
  const resolve = getWebpackResolver(loaderContext.getResolve, implementation, includePaths);
  return function importer(originalUrl, prev, done) {
    const {
      fromImport
    } = this;
    resolve(prev, originalUrl, fromImport).then(result => {
      // Add the result as dependency.
      // Although we're also using stats.includedFiles, this might come in handy when an error occurs.
      // In this case, we don't get stats.includedFiles from node-sass/sass.
      loaderContext.addDependency(_path.default.normalize(result));

      // By removing the CSS file extension, we trigger node-sass to include the CSS file instead of just linking it.
      done({
        file: result.replace(MATCH_CSS, "")
      });
    })
    // Catch all resolving errors, return the original file and pass responsibility back to other custom importers
    .catch(() => {
      done({
        file: originalUrl
      });
    });
  };
}
let nodeSassJobQueue = null;
const sassModernCompilers = new WeakMap();

/**
 * Verifies that the implementation and version of Sass is supported by this loader.
 *
 * @param {Object} loaderContext
 * @param {Object} implementation
 * @param {Object} options
 * @returns {Function}
 */
function getCompileFn(loaderContext, implementation, options) {
  const isNewSass = implementation.info.includes("dart-sass") || implementation.info.includes("sass-embedded");
  if (isNewSass) {
    if (options.api === "modern") {
      return sassOptions => {
        const {
          data,
          ...rest
        } = sassOptions;
        return implementation.compileStringAsync(data, rest);
      };
    }
    if (options.api === "modern-compiler") {
      return async sassOptions => {
        // eslint-disable-next-line no-underscore-dangle
        const webpackCompiler = loaderContext._compiler;
        const {
          data,
          ...rest
        } = sassOptions;

        // Some people can run the loader in a multi-threading way;
        // there is no webpack compiler object in such case.
        if (webpackCompiler) {
          if (!sassModernCompilers.has(webpackCompiler)) {
            // Create a long-running compiler process that can be reused
            // for compiling individual files.
            const compiler = await implementation.initAsyncCompiler();

            // Check again because awaiting the initialization function
            // introduces a race condition.
            if (!sassModernCompilers.has(webpackCompiler)) {
              sassModernCompilers.set(webpackCompiler, compiler);
              webpackCompiler.hooks.shutdown.tap("sass-loader", () => {
                compiler.dispose();
              });
            }
          }
          return sassModernCompilers.get(webpackCompiler).compileStringAsync(data, rest);
        }
        return implementation.compileStringAsync(data, rest);
      };
    }
    return sassOptions => new Promise((resolve, reject) => {
      implementation.render(sassOptions, (error, result) => {
        if (error) {
          reject(error);
          return;
        }
        resolve(result);
      });
    });
  }
  if (options.api === "modern" || options.api === "modern-compiler") {
    throw new Error("Modern API is not supported for 'node-sass'");
  }

  // There is an issue with node-sass when async custom importers are used
  // See https://github.com/sass/node-sass/issues/857#issuecomment-93594360
  // We need to use a job queue to make sure that one thread is always available to the UV lib
  if (nodeSassJobQueue === null) {
    const threadPoolSize = Number(process.env.UV_THREADPOOL_SIZE || 4);
    // Only used for `node-sass`, so let's load it lazily
    // eslint-disable-next-line global-require
    const async = require("neo-async");
    nodeSassJobQueue = async.queue(implementation.render.bind(implementation), threadPoolSize - 1);
  }
  return sassOptions => new Promise((resolve, reject) => {
    nodeSassJobQueue.push.bind(nodeSassJobQueue)(sassOptions, (error, result) => {
      if (error) {
        reject(error);
        return;
      }
      resolve(result);
    });
  });
}
const ABSOLUTE_SCHEME = /^[A-Za-z0-9+\-.]+:/;

/**
 * @param {string} source
 * @returns {"absolute" | "scheme-relative" | "path-absolute" | "path-absolute"}
 */
function getURLType(source) {
  if (source[0] === "/") {
    if (source[1] === "/") {
      return "scheme-relative";
    }
    return "path-absolute";
  }
  if (IS_NATIVE_WIN32_PATH.test(source)) {
    return "path-absolute";
  }
  return ABSOLUTE_SCHEME.test(source) ? "absolute" : "path-relative";
}
function normalizeSourceMap(map, rootContext) {
  const newMap = map;

  // result.map.file is an optional property that provides the output filename.
  // Since we don't know the final filename in the webpack build chain yet, it makes no sense to have it.
  // eslint-disable-next-line no-param-reassign
  if (typeof newMap.file !== "undefined") {
    delete newMap.file;
  }

  // eslint-disable-next-line no-param-reassign
  newMap.sourceRoot = "";

  // node-sass returns POSIX paths, that's why we need to transform them back to native paths.
  // This fixes an error on windows where the source-map module cannot resolve the source maps.
  // @see https://github.com/webpack-contrib/sass-loader/issues/366#issuecomment-279460722
  // eslint-disable-next-line no-param-reassign
  newMap.sources = newMap.sources.map(source => {
    const sourceType = getURLType(source);

    // Do no touch `scheme-relative`, `path-absolute` and `absolute` types (except `file:`)
    if (sourceType === "absolute" && /^file:/i.test(source)) {
      return _url.default.fileURLToPath(source);
    } else if (sourceType === "path-relative") {
      return _path.default.resolve(rootContext, _path.default.normalize(source));
    }
    return source;
  });
  return newMap;
}
function errorFactory(error) {
  let message;
  if (error.formatted) {
    message = error.formatted.replace(/^Error: /, "");
  } else {
    // Keep original error if `sassError.formatted` is unavailable
    ({
      message
    } = error);
  }
  const obj = new Error(message, {
    cause: error
  });
  obj.stack = null;
  return obj;
}


sass-loader

description: Sass loader for webpack

license: MIT

repository: webpack-contrib/sass-loader

author: J. Tangelder

type: opencollective

start: npm run build -- -w

clean: del-cli dist

prebuild: npm run clean

build: cross-env NODE_ENV=production babel src -d dist --copy-files

commitlint: commitlint --from=master

security: npm audit --production

lint:prettier: prettier --cache --list-different .

lint:js: eslint --cache .

lint:spelling: cspell --cache --no-must-find-files --quiet "**/*.*"

lint: npm-run-all -l -p "lint:**"

test:only: cross-env NODE_ENV=test jest

fix:js: npm run lint:js -- --fix

fix:prettier: npm run lint:prettier -- --write

fix: npm-run-all -l fix:js fix:prettier

test:watch: npm run test:only -- --watch

test:manual: npm run build && webpack-dev-server test/manual/src/index.js --open --config test/manual/webpack.config.js

test:coverage: npm run test:only -- --collectCoverageFrom="src/**/*.js" --coverage

pretest: npm run lint

test: npm run test:coverage

prepare: husky && npm run build

release: standard-version

keywords: sass libsass webpack loader


code:
A pure JavaScript implementation of [Sass][sass]. **Sass makes CSS fun again**.

[sass]: https://sass-lang.com/

This package is a distribution of [Dart Sass][], compiled to pure JavaScript
with no native code or external dependencies. It provides a command-line `sass`
executable and a Node.js API.

[Dart Sass]: https://github.com/sass/dart-sass

* [Usage](#usage)
* [See Also](#see-also)
* [Behavioral Differences from Ruby Sass](#behavioral-differences-from-ruby-sass)

## Usage

You can install Sass globally using `npm install -g sass` which will provide
access to the `sass` executable. You can also add it to your project using
`npm install --save-dev sass`. This provides the executable as well as a
library:

[npm]: https://www.npmjs.com/package/sass

```js
const sass = require('sass');

const result = sass.compile(scssFilename);

// OR

// Note that `compileAsync()` is substantially slower than `compile()`.
const result = await sass.compileAsync(scssFilename);
```

See [the Sass website][js api] for full API documentation.

[js api]: https://sass-lang.com/documentation/js-api

### Legacy API

Dart Sass also supports an older JavaScript API that's fully compatible with
[Node Sass] (with a few exceptions listed below), with support for both the
[`render()`] and [`renderSync()`] functions. This API is considered deprecated
and will be removed in Dart Sass 2.0.0, so it should be avoided in new projects.

[Node Sass]: https://github.com/sass/node-sass
[`render()`]: https://sass-lang.com/documentation/js-api/functions/render
[`renderSync()`]: https://sass-lang.com/documentation/js-api/functions/renderSync

Sass's support for the legacy JavaScript API has the following limitations:

* Only the `"expanded"` and `"compressed"` values of [`outputStyle`] are
  supported.

* Dart Sass doesn't support the [`precision`] option. Dart Sass defaults to a
  sufficiently high precision for all existing browsers, and making this
  customizable would make the code substantially less efficient.

* Dart Sass doesn't support the [`sourceComments`] option. Source maps are the
  recommended way of locating the origin of generated selectors.

[`outputStyle`]: https://sass-lang.com/documentation/js-api/interfaces/LegacySharedOptions#outputStyle
[`precision`]: https://github.com/sass/node-sass#precision
[`sourceComments`]: https://github.com/sass/node-sass#sourcecomments

## See Also

* [Dart Sass][], from which this package is compiled, can be used either as a
  stand-alone executable or as a Dart library. Running Dart Sass on the Dart VM
  is substantially faster than running the pure JavaScript version, so this may
  be appropriate for performance-sensitive applications. The Dart API is also
  (currently) more user-friendly than the JavaScript API. See
  [the Dart Sass README][Using Dart Sass] for details on how to use it.

* [Node Sass][], which is a wrapper around [LibSass][], the C++ implementation
  of Sass. Node Sass supports the same API as this package and is also faster
  (although it's usually a little slower than Dart Sass). However, it requires a
  native library which may be difficult to install, and it's generally slower to
  add features and fix bugs.

[Using Dart Sass]: https://github.com/sass/dart-sass#using-dart-sass
[Node Sass]: https://www.npmjs.com/package/node-sass
[LibSass]: https://sass-lang.com/libsass

## Behavioral Differences from Ruby Sass

There are a few intentional behavioral differences between Dart Sass and Ruby
Sass. These are generally places where Ruby Sass has an undesired behavior, and
it's substantially easier to implement the correct behavior than it would be to
implement compatible behavior. These should all have tracking bugs against Ruby
Sass to update the reference behavior.

1. `@extend` only accepts simple selectors, as does the second argument of
   `selector-extend()`. See [issue 1599][].

2. Subject selectors are not supported. See [issue 1126][].

3. Pseudo selector arguments are parsed as `<declaration-value>`s rather than
   having a more limited custom parsing. See [issue 2120][].

4. The numeric precision is set to 10. See [issue 1122][].

5. The indented syntax parser is more flexible: it doesn't require consistent
   indentation across the whole document. See [issue 2176][].

6. Colors do not support channel-by-channel arithmetic. See [issue 2144][].

7. Unitless numbers aren't `==` to unit numbers with the same value. In
   addition, map keys follow the same logic as `==`-equality. See
   [issue 1496][].

8. `rgba()` and `hsla()` alpha values with percentage units are interpreted as
   percentages. Other units are forbidden. See [issue 1525][].

9. Too many variable arguments passed to a function is an error. See
   [issue 1408][].

10. Allow `@extend` to reach outside a media query if there's an identical
    `@extend` defined outside that query. This isn't tracked explicitly, because
    it'll be irrelevant when [issue 1050][] is fixed.

11. Some selector pseudos containing placeholder selectors will be compiled
    where they wouldn't be in Ruby Sass. This better matches the semantics of
    the selectors in question, and is more efficient. See [issue 2228][].

12. The old-style `:property value` syntax is not supported in the indented
    syntax. See [issue 2245][].

13. The reference combinator is not supported. See [issue 303][].

14. Universal selector unification is symmetrical. See [issue 2247][].

15. `@extend` doesn't produce an error if it matches but fails to unify. See
    [issue 2250][].

16. Dart Sass currently only supports UTF-8 documents. We'd like to support
    more, but Dart currently doesn't support them. See [dart-lang/sdk#11744][],
    for example.

[issue 1599]: https://github.com/sass/sass/issues/1599
[issue 1126]: https://github.com/sass/sass/issues/1126
[issue 2120]: https://github.com/sass/sass/issues/2120
[issue 1122]: https://github.com/sass/sass/issues/1122
[issue 2176]: https://github.com/sass/sass/issues/2176
[issue 2144]: https://github.com/sass/sass/issues/2144
[issue 1496]: https://github.com/sass/sass/issues/1496
[issue 1525]: https://github.com/sass/sass/issues/1525
[issue 1408]: https://github.com/sass/sass/issues/1408
[issue 1050]: https://github.com/sass/sass/issues/1050
[issue 2228]: https://github.com/sass/sass/issues/2228
[issue 2245]: https://github.com/sass/sass/issues/2245
[issue 303]: https://github.com/sass/sass/issues/303
[issue 2247]: https://github.com/sass/sass/issues/2247
[issue 2250]: https://github.com/sass/sass/issues/2250
[dart-lang/sdk#11744]: https://github.com/dart-lang/sdk/issues/11744

Disclaimer: this is not an official Google product.


sass

description: A pure JavaScript implementation of Sass.

type: git

keywords: style scss sass preprocessor css


code:
require('./sass.dart.js');
const library = globalThis._cliPkgExports.pop();
if (globalThis._cliPkgExports.length === 0) delete globalThis._cliPkgExports;
library.load({
  immutable: require("immutable"),
});

module.exports = library;


code:
import * as immutable from "immutable"
import "./sass.dart.js";

const _cliPkgLibrary = globalThis._cliPkgExports.pop();
if (globalThis._cliPkgExports.length === 0) delete globalThis._cliPkgExports;
const _cliPkgExports = {};
_cliPkgLibrary.load({immutable}, _cliPkgExports);

export const compile = _cliPkgExports.compile;
export const compileAsync = _cliPkgExports.compileAsync;
export const compileString = _cliPkgExports.compileString;
export const compileStringAsync = _cliPkgExports.compileStringAsync;
export const initCompiler = _cliPkgExports.initCompiler;
export const initAsyncCompiler = _cliPkgExports.initAsyncCompiler;
export const Compiler = _cliPkgExports.Compiler;
export const AsyncCompiler = _cliPkgExports.AsyncCompiler;
export const Logger = _cliPkgExports.Logger;
export const SassArgumentList = _cliPkgExports.SassArgumentList;
export const SassBoolean = _cliPkgExports.SassBoolean;
export const SassCalculation = _cliPkgExports.SassCalculation;
export const CalculationOperation = _cliPkgExports.CalculationOperation;
export const CalculationInterpolation = _cliPkgExports.CalculationInterpolation;
export const SassColor = _cliPkgExports.SassColor;
export const SassFunction = _cliPkgExports.SassFunction;
export const SassList = _cliPkgExports.SassList;
export const SassMap = _cliPkgExports.SassMap;
export const SassMixin = _cliPkgExports.SassMixin;
export const SassNumber = _cliPkgExports.SassNumber;
export const SassString = _cliPkgExports.SassString;
export const Value = _cliPkgExports.Value;
export const CustomFunction = _cliPkgExports.CustomFunction;
export const ListSeparator = _cliPkgExports.ListSeparator;
export const sassFalse = _cliPkgExports.sassFalse;
export const sassNull = _cliPkgExports.sassNull;
export const sassTrue = _cliPkgExports.sassTrue;
export const Exception = _cliPkgExports.Exception;
export const PromiseOr = _cliPkgExports.PromiseOr;
export const info = _cliPkgExports.info;
export const render = _cliPkgExports.render;
export const renderSync = _cliPkgExports.renderSync;
export const TRUE = _cliPkgExports.TRUE;
export const FALSE = _cliPkgExports.FALSE;
export const NULL = _cliPkgExports.NULL;
export const types = _cliPkgExports.types;
export const NodePackageImporter = _cliPkgExports.NodePackageImporter;
export const deprecations = _cliPkgExports.deprecations;
export const Version = _cliPkgExports.Version;


code:
#!/usr/bin/env node

require('./sass.dart.js');
var library = globalThis._cliPkgExports.pop();
if (globalThis._cliPkgExports.length === 0) delete globalThis._cliPkgExports;

library.load({
  readline: require("readline"),
  chokidar: require("chokidar"),
  util: require("util"),
  stream: require("stream"),
  nodeModule: require("module"),
  fs: require("fs"),
  immutable: require("immutable"),
});

library.cli_pkg_main_0_(process.argv.slice(2));


code:
require('./sass.dart.js');
const library = globalThis._cliPkgExports.pop();
if (globalThis._cliPkgExports.length === 0) delete globalThis._cliPkgExports;
library.load({
  util: require("util"),
  stream: require("stream"),
  nodeModule: require("module"),
  fs: require("fs"),
  immutable: require("immutable"),
});

module.exports = library;


code:
import cjs from "./sass.node.js";

export const compile = cjs.compile;
export const compileAsync = cjs.compileAsync;
export const compileString = cjs.compileString;
export const compileStringAsync = cjs.compileStringAsync;
export const initCompiler = cjs.initCompiler;
export const initAsyncCompiler = cjs.initAsyncCompiler;
export const Compiler = cjs.Compiler;
export const AsyncCompiler = cjs.AsyncCompiler;
export const Logger = cjs.Logger;
export const SassArgumentList = cjs.SassArgumentList;
export const SassBoolean = cjs.SassBoolean;
export const SassCalculation = cjs.SassCalculation;
export const CalculationOperation = cjs.CalculationOperation;
export const CalculationInterpolation = cjs.CalculationInterpolation;
export const SassColor = cjs.SassColor;
export const SassFunction = cjs.SassFunction;
export const SassList = cjs.SassList;
export const SassMap = cjs.SassMap;
export const SassMixin = cjs.SassMixin;
export const SassNumber = cjs.SassNumber;
export const SassString = cjs.SassString;
export const Value = cjs.Value;
export const CustomFunction = cjs.CustomFunction;
export const ListSeparator = cjs.ListSeparator;
export const sassFalse = cjs.sassFalse;
export const sassNull = cjs.sassNull;
export const sassTrue = cjs.sassTrue;
export const Exception = cjs.Exception;
export const PromiseOr = cjs.PromiseOr;
export const info = cjs.info;
export const render = cjs.render;
export const renderSync = cjs.renderSync;
export const TRUE = cjs.TRUE;
export const FALSE = cjs.FALSE;
export const NULL = cjs.NULL;
export const types = cjs.types;
export const NodePackageImporter = cjs.NodePackageImporter;
export const deprecations = cjs.deprecations;
export const Version = cjs.Version;

let printedDefaultExportDeprecation = false;
function defaultExportDeprecation() {
  if (printedDefaultExportDeprecation) return;
  printedDefaultExportDeprecation = true;
  console.error(
      "`import sass from 'sass'` is deprecated.\n" +
      "Please use `import * as sass from 'sass'` instead.");
}

export default {
  get compile() {
    defaultExportDeprecation();
    return cjs.compile;
  },
  get compileAsync() {
    defaultExportDeprecation();
    return cjs.compileAsync;
  },
  get compileString() {
    defaultExportDeprecation();
    return cjs.compileString;
  },
  get compileStringAsync() {
    defaultExportDeprecation();
    return cjs.compileStringAsync;
  },
  get initCompiler() {
    defaultExportDeprecation();
    return cjs.initCompiler;
  },
  get initAsyncCompiler() {
    defaultExportDeprecation();
    return cjs.initAsyncCompiler;
  },
  get Compiler() {
    defaultExportDeprecation();
    return cjs.Compiler;
  },
  get AsyncCompiler() {
    defaultExportDeprecation();
    return cjs.AsyncCompiler;
  },
  get Logger() {
    defaultExportDeprecation();
    return cjs.Logger;
  },
  get SassArgumentList() {
    defaultExportDeprecation();
    return cjs.SassArgumentList;
  },
  get SassBoolean() {
    defaultExportDeprecation();
    return cjs.SassBoolean;
  },
  get SassCalculation() {
    defaultExportDeprecation();
    return cjs.SassCalculation;
  },
  get CalculationOperation() {
    defaultExportDeprecation();
    return cjs.CalculationOperation;
  },
  get CalculationInterpolation() {
    defaultExportDeprecation();
    return cjs.CalculationInterpolation;
  },
  get SassColor() {
    defaultExportDeprecation();
    return cjs.SassColor;
  },
  get SassFunction() {
    defaultExportDeprecation();
    return cjs.SassFunction;
  },
  get SassList() {
    defaultExportDeprecation();
    return cjs.SassList;
  },
  get SassMap() {
    defaultExportDeprecation();
    return cjs.SassMap;
  },
  get SassMixin() {
    defaultExportDeprecation();
    return cjs.SassMixin;
  },
  get SassNumber() {
    defaultExportDeprecation();
    return cjs.SassNumber;
  },
  get SassString() {
    defaultExportDeprecation();
    return cjs.SassString;
  },
  get Value() {
    defaultExportDeprecation();
    return cjs.Value;
  },
  get CustomFunction() {
    defaultExportDeprecation();
    return cjs.CustomFunction;
  },
  get ListSeparator() {
    defaultExportDeprecation();
    return cjs.ListSeparator;
  },
  get sassFalse() {
    defaultExportDeprecation();
    return cjs.sassFalse;
  },
  get sassNull() {
    defaultExportDeprecation();
    return cjs.sassNull;
  },
  get sassTrue() {
    defaultExportDeprecation();
    return cjs.sassTrue;
  },
  get Exception() {
    defaultExportDeprecation();
    return cjs.Exception;
  },
  get PromiseOr() {
    defaultExportDeprecation();
    return cjs.PromiseOr;
  },
  get info() {
    defaultExportDeprecation();
    return cjs.info;
  },
  get render() {
    defaultExportDeprecation();
    return cjs.render;
  },
  get renderSync() {
    defaultExportDeprecation();
    return cjs.renderSync;
  },
  get TRUE() {
    defaultExportDeprecation();
    return cjs.TRUE;
  },
  get FALSE() {
    defaultExportDeprecation();
    return cjs.FALSE;
  },
  get NULL() {
    defaultExportDeprecation();
    return cjs.NULL;
  },
  get types() {
    defaultExportDeprecation();
    return cjs.types;
  },
  get NodePackageImporter() {
    defaultExportDeprecation();
    return cjs.NodePackageImporter;
  },
  get deprecations() {
    defaultExportDeprecation();
    return cjs.deprecations;
  },
  get Version() {
    defaultExportDeprecation();
    return cjs.Version;
  },
};


code:
import {RawSourceMap} from 'source-map-js';

import {Options, StringOptions} from './options';

/**
 * The result of compiling Sass to CSS. Returned by {@link compile}, {@link
 * compileAsync}, {@link compileString}, and {@link compileStringAsync}.
 *
 * @category Compile
 */
export interface CompileResult {
  /**
   * The generated CSS.
   *
   * Note that this *never* includes a `sourceMapUrl` comment—it's up to the
   * caller to determine where to save the source map and how to link to it from
   * the stylesheet.
   */
  css: string;

  /**
   * The canonical URLs of all the stylesheets that were loaded during the
   * Sass compilation. The order of these URLs is not guaranteed.
   */
  loadedUrls: URL[];

  /**
   * The object representation of the source map that maps locations in the
   * generated CSS back to locations in the Sass source code.
   *
   * This typically uses absolute `file:` URLs to refer to Sass files, although
   * this can be controlled by having a custom {@link Importer} return {@link
   * ImporterResult.sourceMapUrl}.
   *
   * This is set if and only if {@link Options.sourceMap} is `true`.
   */
  sourceMap?: RawSourceMap;
}

/**
 * The result of creating a synchronous compiler. Returned by
 * {@link initCompiler}.
 *
 * @category Compile
 */
export class Compiler {
  /**
   * Throws an error if constructed directly, instead of via
   * {@link initCompiler}.
   */
  private constructor();

  /**
   * The {@link compile} method exposed through a Compiler instance while it is
   * active. If this is called after {@link dispose} on the Compiler
   * instance, an error will be thrown.
   *
   * During the Compiler instance's lifespan, given the same input, this will
   * return an identical result to the {@link compile} method exposed at the
   * module root.
   */
  compile(path: string, options?: Options<'sync'>): CompileResult;

  /**
   * The {@link compileString} method exposed through a Compiler instance while
   * it is active. If this is called after {@link dispose} on the Compiler
   * instance, an error will be thrown.
   *
   * During the Compiler instance's lifespan, given the same input, this will
   * return an identical result to the {@link compileString} method exposed at
   * the module root.
   */
  compileString(source: string, options?: StringOptions<'sync'>): CompileResult;

  /**
   * Ends the lifespan of this Compiler instance. After this is invoked, all
   * calls to the Compiler instance's {@link compile} or {@link compileString}
   * methods will result in an error.
   */
  dispose(): void;
}

/**
 * The result of creating an asynchronous compiler. Returned by
 * {@link initAsyncCompiler}.
 *
 * @category Compile
 */
export class AsyncCompiler {
  /**
   * Throws an error if constructed directly, instead of via
   * {@link initAsyncCompiler}.
   */
  private constructor();

  /**
   * The {@link compileAsync} method exposed through an Async Compiler instance
   * while it is active. If this is called after {@link dispose} on the Async
   * Compiler instance, an error will be thrown.
   *
   * During the Async Compiler instance's lifespan, given the same input, this
   * will return an identical result to the {@link compileAsync} method exposed
   * at the module root.
   */
  compileAsync(
    path: string,
    options?: Options<'async'>
  ): Promise<CompileResult>;

  /**
   * The {@link compileStringAsync} method exposed through an Async Compiler
   * instance while it is active. If this is called after {@link dispose} on the
   * Async Compiler instance, an error will be thrown.
   *
   * During the Async Compiler instance's lifespan, given the same input, this
   * will return an identical result to the {@link compileStringAsync} method
   * exposed at the module root.
   */
  compileStringAsync(
    source: string,
    options?: StringOptions<'async'>
  ): Promise<CompileResult>;

  /**
   * Ends the lifespan of this Async Compiler instance. After this is invoked,
   * all subsequent calls to the Compiler instance's `compileAsync` or
   * `compileStringAsync` methods will result in an error.
   *
   * Any compilations that are submitted before `dispose` will not be cancelled,
   * and will be allowed to settle.
   *
   * After all compilations have been settled and Sass completes any internal
   * task cleanup, `dispose` will resolve its promise.
   */
  dispose(): Promise<void>;
}

/**
 * Synchronously compiles the Sass file at `path` to CSS. If it succeeds it
 * returns a {@link CompileResult}, and if it fails it throws an {@link
 * Exception}.
 *
 * This only allows synchronous {@link Importer}s and {@link CustomFunction}s.
 *
 * **Heads up!** When using the [sass-embedded] npm package for single
 * compilations, **{@link compileAsync} is almost always faster than
 * {@link compile}**, due to the overhead of emulating synchronous messaging
 * with worker threads and concurrent compilations being blocked on main thread.
 *
 * If you are running multiple compilations with the [sass-embedded] npm
 * package, using a {@link Compiler} will provide some speed improvements over
 * the module-level methods, and an {@link AsyncCompiler} will be much faster.
 *
 * [sass-embedded]: https://www.npmjs.com/package/sass-embedded
 *
 * @example
 *
 * ```js
 * const sass = require('sass');
 *
 * const result = sass.compile("style.scss");
 * console.log(result.css);
 * ```
 *
 * @category Compile
 * @compatibility dart: "1.45.0", node: false
 */
export function compile(path: string, options?: Options<'sync'>): CompileResult;

/**
 * Asynchronously compiles the Sass file at `path` to CSS. Returns a promise
 * that resolves with a {@link CompileResult} if it succeeds and rejects with an
 * {@link Exception} if it fails.
 *
 * This only allows synchronous or asynchronous {@link Importer}s and
 * {@link CustomFunction}s.
 *
 * **Heads up!** When using the `sass` npm package, **{@link compile} is almost
 * twice as fast as {@link compileAsync}**, due to the overhead of making the
 * entire evaluation process asynchronous.
 *
 * @example
 *
 * ```js
 * const sass = require('sass');
 *
 * const result = await sass.compileAsync("style.scss");
 * console.log(result.css);
 * ```
 *
 * @category Compile
 * @compatibility dart: "1.45.0", node: false
 */
export function compileAsync(
  path: string,
  options?: Options<'async'>
): Promise<CompileResult>;

/**
 * Synchronously compiles a stylesheet whose contents is `source` to CSS. If it
 * succeeds it returns a {@link CompileResult}, and if it fails it throws an
 * {@link Exception}.
 *
 * This only allows synchronous {@link Importer}s and {@link CustomFunction}s.
 *
 * **Heads up!** When using the [sass-embedded] npm package for single
 * compilations, **{@link compileStringAsync} is almost always faster than
 * {@link compileString}**, due to the overhead of emulating synchronous
 * messaging with worker threads and concurrent compilations being blocked on
 * main thread.
 *
 * If you are running multiple compilations with the [sass-embedded] npm
 * package, using a {@link Compiler} will provide some speed improvements over
 * the module-level methods, and an {@link AsyncCompiler} will be much faster.
 *
 * [sass-embedded]: https://www.npmjs.com/package/sass-embedded
 *
 * @example
 *
 * ```js
 * const sass = require('sass');
 *
 * const result = sass.compileString(`
 * h1 {
 *   font-size: 40px;
 *   code {
 *     font-face: Roboto Mono;
 *   }
 * }`);
 * console.log(result.css);
 * ```
 *
 * @category Compile
 * @compatibility dart: "1.45.0", node: false
 */
export function compileString(
  source: string,
  options?: StringOptions<'sync'>
): CompileResult;

/**
 * Asynchronously compiles a stylesheet whose contents is `source` to CSS.
 * Returns a promise that resolves with a {@link CompileResult} if it succeeds
 * and rejects with an {@link Exception} if it fails.
 *
 * This only allows synchronous or asynchronous {@link Importer}s and {@link
 * CustomFunction}s.
 *
 * **Heads up!** When using the `sass` npm package, **{@link compileString} is
 * almost twice as fast as {@link compileStringAsync}**, due to the overhead
 * of making the entire evaluation process asynchronous.
 *
 * @example
 *
 * ```js
 * const sass = require('sass');
 *
 * const result = await sass.compileStringAsync(`
 * h1 {
 *   font-size: 40px;
 *   code {
 *     font-face: Roboto Mono;
 *   }
 * }`);
 * console.log(result.css);
 * ```
 *
 * @category Compile
 * @compatibility dart: "1.45.0", node: false
 */
export function compileStringAsync(
  source: string,
  options?: StringOptions<'async'>
): Promise<CompileResult>;

/**
 * Creates a synchronous {@link Compiler}. Each compiler instance exposes the
 * {@link compile} and {@link compileString} methods within the lifespan of the
 * Compiler. Given identical input, these methods will return results identical
 * to their counterparts exposed at the module root. To use asynchronous
 * compilation, use {@link initAsyncCompiler}.
 *
 * When calling the compile functions multiple times, using a compiler instance
 * with the [sass-embedded] npm package is much faster than using the top-level
 * compilation methods or the [sass] npm package.
 *
 * [sass-embedded]: https://www.npmjs.com/package/sass-embedded
 *
 * [sass]: https://www.npmjs.com/package/sass
 *
 * @example
 *
 * ```js
 * const sass = require('sass');
 * function setup() {
 *   const compiler = sass.initCompiler();
 *   const result1 = compiler.compileString('a {b: c}').css;
 *   const result2 = compiler.compileString('a {b: c}').css;
 *   compiler.dispose();
 *
 *   // throws error
 *   const result3 = sass.compileString('a {b: c}').css;
 * }
 * ```
 * @category Compile
 * @compatibility dart: "1.70.0", node: false
 */
export function initCompiler(): Compiler;

/**
 * Creates an asynchronous {@link AsyncCompiler}. Each compiler
 * instance exposes the {@link compileAsync} and {@link compileStringAsync}
 * methods within the lifespan of the Compiler. Given identical input, these
 * methods will return results identical to their counterparts exposed at the
 * module root. To use synchronous compilation, use {@link initCompiler};
 *
 * When calling the compile functions multiple times, using a compiler instance
 * with the [sass-embedded] npm package is much faster than using the top-level
 * compilation methods or the [sass] npm package.
 *
 * [sass-embedded]: https://www.npmjs.com/package/sass-embedded
 *
 * [sass]: https://www.npmjs.com/package/sass
 *
 * @example
 *
 * ```js
 * const sass = require('sass');
 * async function setup() {
 *   const compiler = await sass.initAsyncCompiler();
 *   const result1 = await compiler.compileStringAsync('a {b: c}').css;
 *   const result2 = await compiler.compileStringAsync('a {b: c}').css;
 *   await compiler.dispose();
 *
 *   // throws error
 *   const result3 = await sass.compileStringAsync('a {b: c}').css;
 * }
 * ```
 * @category Compile
 * @compatibility dart: "1.70.0", node: false
 */
export function initAsyncCompiler(): Promise<AsyncCompiler>;


code:
/**
 * All of the deprecation types currently used by Sass.
 *
 * Any of these IDs or the deprecation objects they point to can be passed to
 * `fatalDeprecations`, `futureDeprecations`, or `silenceDeprecations`.
 */
export interface Deprecations {
  // START AUTOGENERATED LIST
  // Checksum: 309e4f1f008f08379b824ab6094e13df2e18e187

  /**
   * Deprecation for passing a string directly to meta.call().
   *
   * This deprecation was active in the first version of Dart Sass.
   */
  'call-string': Deprecation<'call-string'>;

  /**
   * Deprecation for @elseif.
   *
   * This deprecation became active in Dart Sass 1.3.2.
   */
  elseif: Deprecation<'elseif'>;

  /**
   * Deprecation for @-moz-document.
   *
   * This deprecation became active in Dart Sass 1.7.2.
   */
  'moz-document': Deprecation<'moz-document'>;

  /**
   * Deprecation for imports using relative canonical URLs.
   *
   * This deprecation became active in Dart Sass 1.14.2.
   */
  'relative-canonical': Deprecation<'relative-canonical'>;

  /**
   * Deprecation for declaring new variables with !global.
   *
   * This deprecation became active in Dart Sass 1.17.2.
   */
  'new-global': Deprecation<'new-global'>;

  /**
   * Deprecation for using color module functions in place of plain CSS functions.
   *
   * This deprecation became active in Dart Sass 1.23.0.
   */
  'color-module-compat': Deprecation<'color-module-compat'>;

  /**
   * Deprecation for / operator for division.
   *
   * This deprecation became active in Dart Sass 1.33.0.
   */
  'slash-div': Deprecation<'slash-div'>;

  /**
   * Deprecation for leading, trailing, and repeated combinators.
   *
   * This deprecation became active in Dart Sass 1.54.0.
   */
  'bogus-combinators': Deprecation<'bogus-combinators'>;

  /**
   * Deprecation for ambiguous + and - operators.
   *
   * This deprecation became active in Dart Sass 1.55.0.
   */
  'strict-unary': Deprecation<'strict-unary'>;

  /**
   * Deprecation for passing invalid units to built-in functions.
   *
   * This deprecation became active in Dart Sass 1.56.0.
   */
  'function-units': Deprecation<'function-units'>;

  /**
   * Deprecation for using !default or !global multiple times for one variable.
   *
   * This deprecation became active in Dart Sass 1.62.0.
   */
  'duplicate-var-flags': Deprecation<'duplicate-var-flags'>;

  /**
   * Deprecation for passing null as alpha in the JS API.
   *
   * This deprecation became active in Dart Sass 1.62.3.
   */
  'null-alpha': Deprecation<'null-alpha'>;

  /**
   * Deprecation for passing percentages to the Sass abs() function.
   *
   * This deprecation became active in Dart Sass 1.65.0.
   */
  'abs-percent': Deprecation<'abs-percent'>;

  /**
   * Deprecation for using the current working directory as an implicit load path.
   *
   * This deprecation became active in Dart Sass 1.73.0.
   */
  'fs-importer-cwd': Deprecation<'fs-importer-cwd'>;

  /**
   * Deprecation for function and mixin names beginning with --.
   *
   * This deprecation became active in Dart Sass 1.76.0.
   */
  'css-function-mixin': Deprecation<'css-function-mixin'>;

  /**
   * Deprecation for declarations after or between nested rules.
   *
   * This deprecation became active in Dart Sass 1.77.7.
   */
  'mixed-decls': Deprecation<'mixed-decls'>;

  /**
   * Deprecation for @import rules.
   *
   * This deprecation is not yet active, but will be soon.
   */
  import: Deprecation<'import'>;

  // END AUTOGENERATED LIST

  /**
   * Used for any user-emitted deprecation warnings.
   */
  'user-authored': Deprecation<'user-authored', 'user'>;
}

/**
 * Either a deprecation or its ID, either of which can be passed to any of
 * the relevant compiler options.
 *
 * @category Messages
 * @compatibility dart: "1.74.0", node: false
 */
export type DeprecationOrId = Deprecation | keyof Deprecations;

/**
 * The possible statuses that each deprecation can have.
 *
 * "active" deprecations are currently emitting deprecation warnings.
 * "future" deprecations are not yet active, but will be in the future.
 * "obsolete" deprecations were once active, but no longer are.
 *
 * The only "user" deprecation is "user-authored", which is used for deprecation
 * warnings coming from user code.
 *
 * @category Messages
 * @compatibility dart: "1.74.0", node: false
 */
export type DeprecationStatus = 'active' | 'user' | 'future' | 'obsolete';

/**
 * A deprecated feature in the language.
 *
 * @category Messages
 * @compatibility dart: "1.74.0", node: false
 */
export interface Deprecation<
  id extends keyof Deprecations = keyof Deprecations,
  status extends DeprecationStatus = DeprecationStatus
> {
  /** The unique ID of this deprecation. */
  id: id;

  /** The current status of this deprecation. */
  status: status;

  /** A human-readable description of this deprecation. */
  description?: string;

  /** The version this deprecation first became active in. */
  deprecatedIn: status extends 'future' | 'user' ? null : Version;

  /** The version this deprecation became obsolete in. */
  obsoleteIn: status extends 'obsolete' ? Version : null;
}

/**
 * A semantic version of the compiler.
 *
 * @category Messages
 * @compatibility dart: "1.74.0", node: false
 */
export class Version {
  /**
   * Constructs a new version.
   *
   * All components must be non-negative integers.
   *
   * @param major - The major version.
   * @param minor - The minor version.
   * @param patch - The patch version.
   */
  constructor(major: number, minor: number, patch: number);
  readonly major: number;
  readonly minor: number;
  readonly patch: number;

  /**
   * Parses a version from a string.
   *
   * This throws an error if a valid version can't be parsed.
   *
   * @param version - A string in the form "major.minor.patch".
   */
  static parse(version: string): Version;
}

/**
 * An object containing all deprecation types.
 *
 * @category Messages
 * @compatibility dart: "1.74.0", node: false
 */
export const deprecations: Deprecations;


code:
import {SourceSpan} from './logger';

/**
 * An exception thrown because a Sass compilation failed.
 *
 * @category Other
 */
export class Exception extends Error {
  private constructor();

  /**
   * A human-friendly representation of the exception.
   *
   * Because many tools simply print `Error.message` directly, this includes not
   * only the textual description of what went wrong (the {@link sassMessage})
   * but also an indication of where in the Sass stylesheet the error occurred
   * (the {@link span}) and the Sass stack trace at the point of error (the
   * {@link sassStack}).
   */
  message: string;

  /**
   * A textual description of what went wrong.
   *
   * Unlike {@link message}, this does *not* include representations of {@link
   * span} or {@link sassStack}.
   */
  readonly sassMessage: string;

  /**
   * A human-friendly representation of the Sass stack trace at the point of
   * error.
   */
  readonly sassStack: string;

  /** The location the error occurred in the Sass file that triggered it. */
  readonly span: SourceSpan;

  /** Returns the same string as {@link message}. */
  toString(): string;
}