{"_id":"sass-loader@17.1.0","bugs":{"url":"https://github.com/webpack/sass-loader/issues"},"dist":{"shasum":"1100c176be08afd664baeecbb542aa02fd85d9c1","tarball":"http://registry-npm.ywwl.com/sass-loader/download/sass-loader-17.1.0.tgz","fileCount":12,"integrity":"sha512-EZ/u/bLkAErTKvIq/f81Bz6tgL/5Brt8hWOABdTsVdO+nX0PWx2rQhR6fyxVME+MhnQrrwecMDlm2G1y07hhpQ==","signatures":[{"sig":"MEUCIQCc3f6p99uOjk40tOErWdCrPC261APnCdocmFbpeko8xwIgNkSECiAum/KZB7wiaz5YBXRk4rk1CI1VdRrAL+WRTUM=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCB9NttJMJpO4WPrVfUn1xkkMrnG48fwGMShng82pH0FQIhAJHNHX4u4PK8lAsIpqhtw15f9YBNwTEZyTPIQJnktvTe"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/sass-loader@17.1.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":112872,"size":22651,"noattachment":false,"key":"/sass-loader/-/sass-loader-17.1.0.tgz"},"main":"./dist/cjs/index.js","name":"sass-loader","type":"module","types":"./types/index.d.ts","author":{"name":"J. Tangelder"},"module":"./dist/esm/index.js","engines":{"node":">= 22.11.0"},"exports":{".":{"types":"./types/index.d.ts","import":"./dist/esm/index.js","default":"./dist/esm/index.js","require":"./dist/cjs/index.js"},"./package.json":"./package.json"},"funding":{"url":"https://opencollective.com/webpack","type":"opencollective"},"gitHead":"35cf965aa2c861d04360855f71858399f64a3729","license":"MIT","scripts":{"fix":"npm run fix:code && npm run fmt","fmt":"npm run fmt:check -- --write","lint":"npm-run-all -l -p \"lint:**\" && npm run fmt:check","test":"npm run test:base","build":"npm-run-all -p \"build:*\"","clean":"del-cli dist types","prepare":"husky && npm run build","pretest":"npm run lint","release":"npm run build && changeset publish","version":"changeset version","fix:code":"npm run lint:code -- --fix","prebuild":"npm run clean","security":"npm audit --production","build:cjs":"babel src -d dist/cjs --env-name cjs --copy-files --no-copy-ignored && node -e \"const fs=require('fs');fs.writeFileSync('dist/cjs/package.json','{\\\"type\\\":\\\"commonjs\\\"}\\n');fs.appendFileSync('dist/cjs/index.js','module.exports = exports.default;\\nmodule.exports.default = exports.default;\\n')\"","build:esm":"babel src -d dist/esm --env-name esm --copy-files --no-copy-ignored","fmt:check":"prettier --list-different --cache --ignore-unknown .","lint:code":"eslint --cache .","test:base":"node --import ./test/setup-snapshots.js --test --test-force-exit --test-reporter=dot --test-reporter-destination=stdout --experimental-test-module-mocks","lint:types":"tsc --pretty --noEmit","build:types":"tsc && prettier \"types/**/*.ts\" --write","lint:spelling":"cspell --cache --no-must-find-files --quiet \"**/*.*\"","test:coverage":"npm run test:base -- --experimental-test-coverage --test-reporter=lcov --test-reporter-destination=coverage.lcov --test-coverage-include=\"src/**/*.js\""},"version":"17.1.0","_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"c248c6ff-ce4f-4821-a07e-a8282582be9e"}},"homepage":"https://github.com/webpack/sass-loader","keywords":["sass","libsass","webpack","loader"],"repository":{"url":"git+https://github.com/webpack/sass-loader.git","type":"git"},"_npmVersion":"11.19.0","description":"Sass loader for webpack","directories":{},"maintainers":[{"name":"evilebottnawi","email":"sheo13666q@gmail.com"},{"name":"sokra","email":"tobias.koppers@googlemail.com"},{"name":"jhnns","email":"mail@johannesewald.de"},{"name":"15000621931","email":"784487301@qq.com"},{"name":"ev1stensberg","email":"evenstensberg@gmail.com"},{"name":"__hai","email":"haijie0619@gmail.com"},{"name":"avivkeller","email":"me@aviv.sh"}],"_nodeVersion":"24.21.0","dependencies":{},"_hasShrinkwrap":false,"devDependencies":{"del":"^8.0.1","sass":"^1.99.0","husky":"^9.1.3","memfs":"^4.57.2","cspell":"^10.0.0","eslint":"^9.38.0","del-cli":"^7.0.0","webpack":"^5.106.2","prettier":"^3.8.3","@babel/cli":"^7.28.6","css-loader":"^7.1.4","typescript":"^6.0.3","@babel/core":"^7.28.6","@types/node":"^22.13.4","file-loader":"^6.2.0","lint-staged":"^17.0.5","npm-run-all":"^4.1.5","bootstrap-v4":"npm:bootstrap@^4.5.3","bootstrap-v5":"npm:bootstrap@^5.3.8","style-loader":"^4.0.0","sass-embedded":"^1.99.0","bootstrap-sass":"^3.4.1","@changesets/cli":"^2.30.0","enhanced-resolve":"^5.21.5","foundation-sites":"^6.7.5","@babel/preset-env":"^7.28.6","eslint-config-webpack":"^4.9.6","material-components-web":"^9.0.0","@changesets/get-github-info":"^0.8.0"},"peerDependencies":{"sass":"^1.3.0","webpack":"^5.0.0","@rspack/core":"0.x || ^1.0.0 || ^2.0.0-0","sass-embedded":"*"},"peerDependenciesMeta":{"sass":{"optional":true},"webpack":{"optional":true},"@rspack/core":{"optional":true},"sass-embedded":{"optional":true}},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/sass-loader_17.1.0_1793120604193_0.32710821399696277"},"readme":"<div align=\"center\">\n  <img height=\"170\"\n    src=\"https://worldvectorlogo.com/logos/sass-1.svg\">\n  <a href=\"https://github.com/webpack/webpack\">\n    <img width=\"200\" height=\"200\"\n      src=\"https://webpack.js.org/assets/icon-square-big.svg\">\n  </a>\n</div>\n\n[![npm][npm]][npm-url]\n[![node][node]][node-url]\n[![tests][tests]][tests-url]\n[![coverage][cover]][cover-url]\n[![discussion][discussion]][discussion-url]\n[![size][size]][size-url]\n[![discord-invite][discord-invite]][discord-url]\n\n# sass-loader\n\nLoads a Sass/SCSS file and compiles it to CSS.\n\n## Getting Started\n\nTo begin, you'll need to install `sass-loader`:\n\n```console\nnpm install sass-loader sass webpack --save-dev\n```\n\nor\n\n```console\nyarn add -D sass-loader sass webpack\n```\n\nor\n\n```console\npnpm add -D sass-loader sass webpack\n```\n\n> [!NOTE]\n>\n> Webpack has [built-in CSS support](https://webpack.js.org/configuration/experiments/#experimentscss), so no extra loaders are required to process the CSS generated by `sass-loader` - just enable `experiments.css` and set the module `type` to `css/auto`.\n>\n> If you prefer the loader-based setup, install [style-loader](https://webpack.js.org/loaders/style-loader/) and [css-loader](https://webpack.js.org/loaders/css-loader/) via `npm i style-loader css-loader` and chain them with `sass-loader` instead.\n\n`sass-loader` requires you to install either [Dart Sass](https://github.com/sass/dart-sass) or [Sass Embedded](https://github.com/sass/embedded-host-node) on your own (more documentation can be found below).\n\nThis allows you to control the versions of all your dependencies and to choose which Sass implementation to use.\n\n> [!NOTE]\n>\n> We highly recommend using [Sass Embedded](https://github.com/sass/embedded-host-node) or [Dart Sass](https://github.com/sass/dart-sass).\n\nUse the `sass-loader` with the built-in CSS support of webpack (the `css/auto` module type) to let webpack handle the generated CSS - it extracts styles into a separate file and injects them into the document.\n\nAlternatively, you can chain the `sass-loader` with the [css-loader](https://github.com/webpack/css-loader) and the [style-loader](https://github.com/webpack/style-loader) to immediately apply all styles to the DOM, or with the [mini-css-extract-plugin](https://github.com/webpack/mini-css-extract-plugin) to extract it into a separate file.\n\nThen add the loader to your webpack configuration. For example:\n\n**app.js**\n\n```js\nimport \"./style.scss\";\n```\n\n**style.scss**\n\n```scss\n$body-color: red;\n\nbody {\n  color: $body-color;\n}\n```\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.s[ac]ss$/i,\n        // Lets webpack handle the generated CSS using its built-in CSS support,\n        // `css/auto` also enables CSS modules for `*.module.scss` files\n        type: \"css/auto\",\n        use: [\n          // Compiles Sass to CSS\n          \"sass-loader\",\n        ],\n      },\n    ],\n  },\n  experiments: {\n    // Enables the built-in CSS support of webpack\n    css: true,\n  },\n};\n```\n\nFinally run `webpack` via your preferred method (e.g., via CLI or an npm script).\n\n> [!NOTE]\n>\n> All examples below use the built-in CSS support of webpack.\n> If you use [css-loader](https://github.com/webpack/css-loader) and [style-loader](https://github.com/webpack/style-loader) (or [mini-css-extract-plugin](https://github.com/webpack/mini-css-extract-plugin)) instead, remove the `type` and `experiments` options and put them before the `sass-loader` in the `use` array:\n>\n> ```js\n> module.exports = {\n>   module: {\n>     rules: [\n>       {\n>         test: /\\.s[ac]ss$/i,\n>         use: [\"style-loader\", \"css-loader\", \"sass-loader\"],\n>       },\n>     ],\n>   },\n> };\n> ```\n\n### The `style` option in `production` mode\n\nFor `production` mode, the `style` option defaults to `compressed` unless otherwise specified in `sassOptions`.\n\n### Resolving `import`, `use` and `forward` at-rules\n\nWebpack provides an [advanced mechanism to resolve files](https://webpack.js.org/concepts/module-resolution/).\n\nThe `sass-loader` uses Sass's custom importer feature to pass every `@use`, `@import` and `@forward` request to the webpack resolving engine, so your webpack [`resolve`](https://webpack.js.org/configuration/resolve/) configuration applies to stylesheets, and you can load Sass modules from `node_modules`:\n\n```scss\n@use \"bootstrap\";\n```\n\n#### How a request is resolved\n\nFor `@use \"theme\"` inside `src/app.scss`, the loader asks webpack for the following and takes the first hit:\n\n1. the partial `src/_theme.sass`, `src/_theme.scss`, `src/_theme.css`\n2. `src/theme.sass`, `src/theme.scss`, `src/theme.css`\n3. `theme` as written, so aliases and package requests resolve\n\nDirectories resolve through their `_index`/`index` file. For `@import` only, the import-only files `_theme.import.scss` and `theme.import.scss` are tried before everything else.\n\nRelative requests win over module ones, so `@use \"theme\"` behaves like `@use \"./theme\"` when both could match. Keeping both `_theme.scss` and `theme.scss` in one directory is ambiguous and Sass reports an error for it, so the order within a directory rarely matters.\n\n#### What your `resolve` configuration controls\n\n- [`alias`](https://webpack.js.org/configuration/resolve/#resolvealias) - applied to every request, and tried before `node_modules`\n- [`modules`](https://webpack.js.org/configuration/resolve/#resolvemodules) - extra directories to look in, e.g. `src`\n- [`byDependency.sass`](https://webpack.js.org/configuration/resolve/#resolvebydependency) - requests are resolved with `dependencyType: \"sass\"`, so this targets stylesheets only\n- [`plugins`](https://webpack.js.org/configuration/resolve/#resolveplugins), [`symlinks`](https://webpack.js.org/configuration/resolve/#resolvesymlinks), [`roots`](https://webpack.js.org/configuration/resolve/#resolveroots) and the rest of the resolver options\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  resolve: {\n    alias: { \"@styles\": path.resolve(__dirname, \"src/styles\") },\n    modules: [path.resolve(__dirname, \"src\"), \"node_modules\"],\n  },\n};\n```\n\n**style.scss**\n\n```scss\n@use \"@styles/theme\" as *; // resolved by `resolve.alias`\n@use \"abstracts\" as *; // resolved by `resolve.modules` to `src/abstracts/_index.scss`\n```\n\nSome options are fixed to match Sass's own algorithm and can't be changed through `resolve`: the extensions are `.sass`, `.scss` and `.css` (so [`resolve.extensions`](https://webpack.js.org/configuration/resolve/#resolveextensions) doesn't apply here), `mainFiles` prefer `_index`/`index`, `mainFields` prefer `sass` and `style` over `main`, and `conditionNames` prefer the `sass` and `style` [export conditions](https://webpack.js.org/guides/package-exports/). Your own `mainFields` and `conditionNames` are kept after those.\n\n#### Packages\n\nA package request resolves through the `sass` and `style` conditions of its `exports` field, falling back to the `sass`, `style` and `main` fields. The [`pkg:` URL scheme](https://sass-lang.com/documentation/at-rules/use/#pkg) is supported as well:\n\n```scss\n@use \"pkg:bootstrap\";\n```\n\n#### When webpack can't resolve a request\n\nThe importer hands the request back to Sass, which then applies its own resolution - [`sassOptions.loadPaths`](#sassoptions), the `SASS_PATH` environment variable and any custom importer you configured.\n\n#### Plain CSS files\n\nSass compiles `@import \"theme.css\"` to a plain CSS `@import`, so the loader leaves it in the output untouched - whatever handles the CSS afterwards (the built-in CSS support of webpack, `css-loader`, or the browser) decides what happens with it. `@use \"theme.css\"` includes the file's content instead, and is resolved like any other request:\n\n```scss\n@import \"theme.css\"; // stays `@import \"theme.css\";` in the output\n@use \"theme.css\"; // inlines the content of the file\n```\n\n#### The `~` prefix\n\nUsing `~` is deprecated and should be removed from your code, but we still support it for historical reasons.\n\nWhy can you remove it? The loader will first try to resolve `@use` as a relative path. If it cannot be resolved, then the loader will try to resolve it inside [`node_modules`](https://webpack.js.org/configuration/resolve/#resolvemodules).\n\nPrepending module paths with a `~` tells webpack to search through [`node_modules`](https://webpack.js.org/configuration/resolve/#resolvemodules).\n\n```scss\n@use \"~bootstrap\";\n```\n\nIt's important to prepend the path with only `~`, because `~/` resolves to the home directory.\n\nWebpack needs to distinguish between `bootstrap` and `~bootstrap` because CSS and Sass files have no special syntax for importing relative files.\n\nWriting `@use \"style.scss\"` is the same as `@use \"./style.scss\";`\n\n### Problems with `url(...)`\n\nSince Sass implementations don't provide [url rewriting](https://github.com/sass/libsass/issues/532), all linked assets must be relative to the output.\n\n- If webpack handles the generated CSS (i.e. the built-in CSS support or the `css-loader`), all URLs must be relative to the entry-file (e.g. `main.scss`).\n- If you're just generating CSS without letting webpack handle it, URLs must be relative to your web root.\n\nYou might be surprised by this first issue, as 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).\n\nThankfully there are two solutions to this problem:\n\n- 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.\n\n- 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`.\n\n## Options\n\n- **[`implementation`](#implementation)**\n- **[`sassOptions`](#sassoptions)**\n- **[`sourceMap`](#sourcemap)**\n- **[`additionalData`](#additionaldata)**\n- **[`webpackImporter`](#webpackimporter)**\n- **[`warnRuleAsWarning`](#warnruleaswarning)**\n- **[`api`](#api)**\n\n### `implementation`\n\nType:\n\n```ts\ntype implementation = object | string;\n```\n\nDefault: `sass`\n\nThe special `implementation` option determines which implementation of Sass to use.\n\nBy default, the loader resolves the implementation based on your dependencies.\nJust add the desired implementation to your `package.json` (`sass` or `sass-embedded` package) and install dependencies.\n\nExample where the `sass-loader` uses the `sass` (`dart-sass`) implementation:\n\n**package.json**\n\n```json\n{\n  \"devDependencies\": {\n    \"sass-loader\": \"^7.2.0\",\n    \"sass\": \"^1.22.10\"\n  }\n}\n```\n\nExample where the `sass-loader` uses the `sass-embedded` implementation:\n\n**package.json**\n\n```json\n{\n  \"devDependencies\": {\n    \"sass-loader\": \"^7.2.0\",\n    \"sass\": \"^1.22.10\"\n  },\n  \"optionalDependencies\": {\n    \"sass-embedded\": \"^1.70.0\"\n  }\n}\n```\n\n> [!NOTE]\n>\n> Using `optionalDependencies` means that `sass-loader` can fallback to `sass` when running on an operating system not supported by `sass-embedded`\n\nBe aware of the order that `sass-loader` will resolve the implementation:\n\n1. `sass-embedded`\n2. `sass`\n\nYou can specify a specific implementation by using the `implementation` option, which accepts one of the above values.\n\n#### `object`\n\nFor example, to always use `Dart Sass`, you'd pass:\n\n```js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.s[ac]ss$/i,\n        type: \"css/auto\",\n        use: [\n          {\n            loader: \"sass-loader\",\n            options: {\n              // Prefer `dart-sass`, even if `sass-embedded` is available\n              implementation: require(\"sass\"),\n            },\n          },\n        ],\n      },\n    ],\n  },\n  experiments: {\n    css: true,\n  },\n};\n```\n\n#### `string`\n\nFor example, to use Dart Sass, you'd pass:\n\n```js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.s[ac]ss$/i,\n        type: \"css/auto\",\n        use: [\n          {\n            loader: \"sass-loader\",\n            options: {\n              // Prefer `dart-sass`, even if `sass-embedded` is available\n              implementation: require.resolve(\"sass\"),\n            },\n          },\n        ],\n      },\n    ],\n  },\n  experiments: {\n    css: true,\n  },\n};\n```\n\n### `sassOptions`\n\nType:\n\n```ts\ntype sassOptions =\n  | import(\"sass\").StringOptionsWithImporter<\"async\">\n  | ((\n      content: string | Buffer,\n      loaderContext: LoaderContext,\n      meta: any,\n    ) => import(\"sass\").StringOptionsWithImporter<\"async\">);\n```\n\nDefault: defaults values for Sass implementation\n\nOptions for [Dart Sass](http://sass-lang.com/dart-sass) or [Sass Embedded](https://github.com/sass/embedded-host-node) implementation.\n\n> [!NOTE]\n>\n> The `charset` option is `true` by default for `dart-sass`. We strongly discourage setting this to `false` because webpack doesn't support files other than `utf-8`.\n\n> [!NOTE]\n>\n> The `syntax` option is `scss` for the `scss` extension, `indented` for the `sass` extension, and `css` for the `css` extension.\n\n> [!NOTE]\n>\n> Options such as `data` and `url` are unavailable and will be ignored.\n\n> ℹ We strongly discourage changing the `sourceMap` option because `sass-loader` sets it automatically when the `sourceMap` option is `true`.\n\nPlease consult their respective documentation before using them:\n\n- [Dart Sass documentation](https://sass-lang.com/documentation/js-api/interfaces/Options) for all available `sass` options.\n- [Sass Embedded documentation](https://github.com/sass/embedded-host-node) for all available `sass-embedded` options.\n\n#### `object`\n\nUse an object for the Sass implementation setup.\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.s[ac]ss$/i,\n        type: \"css/auto\",\n        use: [\n          {\n            loader: \"sass-loader\",\n            options: {\n              sassOptions: {\n                style: \"compressed\",\n                loadPaths: [\"absolute/path/a\", \"absolute/path/b\"],\n              },\n            },\n          },\n        ],\n      },\n    ],\n  },\n  experiments: {\n    css: true,\n  },\n};\n```\n\n#### `function`\n\nAllows configuring the Sass implementation with different options based on the loader context.\n\n```js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.s[ac]ss$/i,\n        type: \"css/auto\",\n        use: [\n          {\n            loader: \"sass-loader\",\n            options: {\n              sassOptions: (loaderContext) => {\n                // More information about available properties https://webpack.js.org/api/loaders/\n                const { resourcePath, rootContext } = loaderContext;\n                const relativePath = path.relative(rootContext, resourcePath);\n\n                if (relativePath === \"styles/foo.scss\") {\n                  return {\n                    loadPaths: [\"absolute/path/c\", \"absolute/path/d\"],\n                  };\n                }\n\n                return {\n                  loadPaths: [\"absolute/path/a\", \"absolute/path/b\"],\n                };\n              },\n            },\n          },\n        ],\n      },\n    ],\n  },\n  experiments: {\n    css: true,\n  },\n};\n```\n\n### `sourceMap`\n\nType:\n\n```ts\ntype sourceMap = boolean;\n```\n\nDefault: depends on the `compiler.devtool` value\n\nEnables/disables generation of source maps.\n\nBy default generation of source maps depends on the [`devtool`](https://webpack.js.org/configuration/devtool/) option.\nAll values enable source map generation except `eval` and `false`.\n\n> ℹ If `true`, the `sourceMap` option from `sassOptions` will be ignored.\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.s[ac]ss$/i,\n        type: \"css/auto\",\n        use: [\n          {\n            loader: \"sass-loader\",\n            options: {\n              sourceMap: true,\n            },\n          },\n        ],\n      },\n    ],\n  },\n  experiments: {\n    css: true,\n  },\n};\n```\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.s[ac]ss$/i,\n        type: \"css/auto\",\n        use: [\n          {\n            loader: \"sass-loader\",\n            options: {\n              sourceMap: true,\n              sassOptions: {\n                style: \"compressed\",\n              },\n            },\n          },\n        ],\n      },\n    ],\n  },\n  experiments: {\n    css: true,\n  },\n};\n```\n\n### `additionalData`\n\nType:\n\n```ts\ntype additionalData =\n  | string\n  | ((content: string | Buffer, loaderContext: LoaderContext) => string);\n```\n\nDefault: `undefined`\n\nPrepends `Sass`/`SCSS` code before the actual entry file.\nIn this case, the `sass-loader` will not override the `data` option but just **prepend** the entry's content.\n\nThis is especially useful when some of your Sass variables depend on the environment:\n\n#### `string`\n\n```js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.s[ac]ss$/i,\n        type: \"css/auto\",\n        use: [\n          {\n            loader: \"sass-loader\",\n            options: {\n              additionalData: `$env: ${process.env.NODE_ENV};`,\n            },\n          },\n        ],\n      },\n    ],\n  },\n  experiments: {\n    css: true,\n  },\n};\n```\n\n#### `function`\n\n##### Sync\n\n```js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.s[ac]ss$/i,\n        type: \"css/auto\",\n        use: [\n          {\n            loader: \"sass-loader\",\n            options: {\n              additionalData: (content, loaderContext) => {\n                // More information about available properties https://webpack.js.org/api/loaders/\n                const { resourcePath, rootContext } = loaderContext;\n                const relativePath = path.relative(rootContext, resourcePath);\n\n                if (relativePath === \"styles/foo.scss\") {\n                  return `$value: 100px;${content}`;\n                }\n\n                return `$value: 200px;${content}`;\n              },\n            },\n          },\n        ],\n      },\n    ],\n  },\n  experiments: {\n    css: true,\n  },\n};\n```\n\n##### Async\n\n```js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.s[ac]ss$/i,\n        type: \"css/auto\",\n        use: [\n          {\n            loader: \"sass-loader\",\n            options: {\n              additionalData: async (content, loaderContext) => {\n                // More information about available properties https://webpack.js.org/api/loaders/\n                const { resourcePath, rootContext } = loaderContext;\n                const relativePath = path.relative(rootContext, resourcePath);\n\n                if (relativePath === \"styles/foo.scss\") {\n                  return `$value: 100px;${content}`;\n                }\n\n                return `$value: 200px;${content}`;\n              },\n            },\n          },\n        ],\n      },\n    ],\n  },\n  experiments: {\n    css: true,\n  },\n};\n```\n\n### `webpackImporter`\n\nType:\n\n```ts\ntype webpackImporter = boolean;\n```\n\nDefault: `true`\n\nEnables/disables the default webpack importer.\n\nThis can improve performance in some cases, though use it with caution because aliases and `@import` at-rules starting with `~` will not work.\nYou can pass your own `importer` to solve this (see [Sass importer documentation](https://sass-lang.com/documentation/js-api/interfaces/LegacyImporter)).\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.s[ac]ss$/i,\n        type: \"css/auto\",\n        use: [\n          {\n            loader: \"sass-loader\",\n            options: {\n              webpackImporter: false,\n            },\n          },\n        ],\n      },\n    ],\n  },\n  experiments: {\n    css: true,\n  },\n};\n```\n\n### `warnRuleAsWarning`\n\nType:\n\n```ts\ntype warnRuleAsWarning = boolean;\n```\n\nDefault: `true`\n\nTreats the `@warn` rule as a webpack warning.\n\n**style.scss**\n\n```scss\n$known-prefixes: webkit, moz, ms, o;\n\n@mixin prefix($property, $value, $prefixes) {\n  @each $prefix in $prefixes {\n    @if not index($known-prefixes, $prefix) {\n      @warn \"Unknown prefix #{$prefix}.\";\n    }\n\n    -#{$prefix}-#{$property}: $value;\n  }\n  #{$property}: $value;\n}\n\n.tilt {\n  // Oops, we typo'd \"webkit\" as \"wekbit\"!\n  @include prefix(transform, rotate(15deg), wekbit ms);\n}\n```\n\nThe presented code will throw a webpack warning instead of logging.\n\nTo ignore unnecessary warnings you can use the [ignoreWarnings](https://webpack.js.org/configuration/other-options/#ignorewarnings) option.\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.s[ac]ss$/i,\n        type: \"css/auto\",\n        use: [\n          {\n            loader: \"sass-loader\",\n            options: {\n              warnRuleAsWarning: true,\n            },\n          },\n        ],\n      },\n    ],\n  },\n  experiments: {\n    css: true,\n  },\n};\n```\n\n### `api`\n\nType:\n\n```ts\ntype api = \"auto\" | \"modern\" | \"modern-compiler\";\n```\n\nDefault: `\"auto\"` for `sass` (`dart-sass`) and `sass-embedded`\n\nAllows you to switch between the `modern` and `modern-compiler` APIs. 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).\n\nWhen `\"auto\"` is used, the loader picks `\"modern-compiler\"` whenever the implementation exposes `initAsyncCompiler` (i.e. recent versions of `sass` and `sass-embedded`) and falls back to `\"modern\"` otherwise. Combined with `sass-embedded`, this yields the best build performance out of the box.\n\n> [!NOTE]\n>\n> Using `modern-compiler` and `sass-embedded` together significantly improves performance and decreases build time. They are now selected automatically by the default `\"auto\"` API.\n\n> [!NOTE]\n>\n> The legacy Sass JS API is no longer supported. If you were using `api: \"legacy\"`, please migrate to the modern API. See the [Sass JS API docs](https://sass-lang.com/documentation/js-api) to learn how to migrate.\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.s[ac]ss$/i,\n        type: \"css/auto\",\n        use: [\n          {\n            loader: \"sass-loader\",\n            options: {\n              api: \"modern-compiler\",\n              sassOptions: {\n                // Your sass options\n              },\n            },\n          },\n        ],\n      },\n    ],\n  },\n  experiments: {\n    css: true,\n  },\n};\n```\n\n## How to enable `@debug` output\n\nBy default, the output of `@debug` messages is disabled.\nAdd the following to **webpack.config.js** to enable them:\n\n```js\nmodule.exports = {\n  stats: {\n    loggingDebug: [\"sass-loader\"],\n  },\n  // ...\n};\n```\n\n## Examples\n\n### Extracts CSS into separate files\n\nFor production builds, it's recommended to extract the CSS from your bundle to enable parallel loading of CSS/JS resources.\n\nThere are five recommended ways to extract a stylesheet from a bundle:\n\n#### 1. [Built-in CSS support](https://webpack.js.org/configuration/experiments/#experimentscss)\n\nWebpack emits CSS into separate files on its own, so nothing but `experiments.css` is required.\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.s[ac]ss$/i,\n        type: \"css/auto\",\n        use: [\"sass-loader\"],\n      },\n    ],\n  },\n  output: {\n    // Both options are optional\n    cssFilename: \"[name].css\",\n    cssChunkFilename: \"[id].css\",\n  },\n  experiments: {\n    css: true,\n  },\n};\n```\n\n#### 2. [mini-css-extract-plugin](https://github.com/webpack/mini-css-extract-plugin)\n\n**webpack.config.js**\n\n```js\nconst MiniCssExtractPlugin = require(\"mini-css-extract-plugin\");\n\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.s[ac]ss$/i,\n        use: [\n          // fallback to style-loader in development\n          process.env.NODE_ENV !== \"production\"\n            ? \"style-loader\"\n            : MiniCssExtractPlugin.loader,\n          \"css-loader\",\n          \"sass-loader\",\n        ],\n      },\n    ],\n  },\n  plugins: [\n    new MiniCssExtractPlugin({\n      // Options similar to the same options in webpackOptions.output\n      // both options are optional\n      filename: \"[name].css\",\n      chunkFilename: \"[id].css\",\n    }),\n  ],\n};\n```\n\n#### 3. [Asset Modules](https://webpack.js.org/guides/asset-modules/)\n\n**webpack.config.js**\n\n```js\nconst path = require(\"node:path\");\n\nmodule.exports = {\n  entry: [path.resolve(__dirname, \"./src/scss/app.scss\")],\n  module: {\n    rules: [\n      {\n        test: /\\.js$/,\n        exclude: /node_modules/,\n        use: [],\n      },\n      {\n        test: /\\.scss$/,\n        exclude: /node_modules/,\n        type: \"asset/resource\",\n        generator: {\n          filename: \"bundle.css\",\n        },\n        use: [\"sass-loader\"],\n      },\n    ],\n  },\n};\n```\n\n#### 4. [extract-loader](https://github.com/peerigon/extract-loader) (simpler, but specialized on the css-loader's output)\n\n#### 5. [file-loader](https://github.com/webpack-contrib/file-loader) (deprecated--should only be used in webpack v4)\n\n**webpack.config.js**\n\n```js\nconst path = require(\"node:path\");\n\nmodule.exports = {\n  entry: [path.resolve(__dirname, \"./src/scss/app.scss\")],\n  module: {\n    rules: [\n      {\n        test: /\\.js$/,\n        exclude: /node_modules/,\n        use: [],\n      },\n      {\n        test: /\\.scss$/,\n        exclude: /node_modules/,\n        use: [\n          {\n            loader: \"file-loader\",\n            options: { outputPath: \"css/\", name: \"[name].min.css\" },\n          },\n          \"sass-loader\",\n        ],\n      },\n    ],\n  },\n};\n```\n\n(source: https://stackoverflow.com/a/60029923/2969615)\n\n### Source maps\n\nEnables/disables generation of source maps.\n\nTo enable CSS source maps, you'll need to pass the `sourceMap` option to the `sass-loader` (and to the `css-loader` too, when you use it).\n\n**webpack.config.js**\n\n```javascript\nmodule.exports = {\n  devtool: \"source-map\", // any \"source-map\"-like devtool is possible\n  module: {\n    rules: [\n      {\n        test: /\\.s[ac]ss$/i,\n        type: \"css/auto\",\n        use: [\n          {\n            loader: \"sass-loader\",\n            options: {\n              sourceMap: true,\n            },\n          },\n        ],\n      },\n    ],\n  },\n  experiments: {\n    css: true,\n  },\n};\n```\n\nIf 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).\nCheckout [test/sourceMap](https://github.com/webpack/sass-loader/tree/main/test) for a working example.\n\n## Contributing\n\nWe welcome all contributions!\nIf you're new here, please take a moment to review our contributing guidelines before submitting issues or pull requests.\n\n[CONTRIBUTING](https://github.com/webpack/sass-loader?tab=contributing-ov-file#contributing)\n\n## License\n\n[MIT](./LICENSE)\n\n[npm]: https://img.shields.io/npm/v/sass-loader.svg\n[npm-url]: https://npmjs.com/package/sass-loader\n[node]: https://img.shields.io/node/v/sass-loader.svg\n[node-url]: https://nodejs.org\n[tests]: https://github.com/webpack/sass-loader/workflows/sass-loader/badge.svg\n[tests-url]: https://github.com/webpack/sass-loader/actions\n[cover]: https://codecov.io/gh/webpack/sass-loader/branch/main/graph/badge.svg\n[cover-url]: https://codecov.io/gh/webpack/sass-loader\n[discussion]: https://img.shields.io/github/discussions/webpack/webpack\n[discussion-url]: https://github.com/webpack/webpack/discussions\n[size]: https://packagephobia.now.sh/badge?p=sass-loader\n[size-url]: https://packagephobia.now.sh/result?p=sass-loader\n[discord-invite]: https://img.shields.io/discord/1180618526436888586?style=flat&logo=discord&logoColor=white&label=discord\n[discord-url]: https://discord.gg/ARKBCXBu\n","publish_time":1793120604291,"_cnpm_publish_time":1793120604291,"dist-tags":{"fix-3.2.2":"3.2.3","latest":"17.1.0","next":"10.0.0-rc.0","version-10":"10.5.2"}}