sass-loader 12.5.0 → 13.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -9,7 +9,6 @@
9
9
 
10
10
  [![npm][npm]][npm-url]
11
11
  [![node][node]][node-url]
12
- [![deps][deps]][deps-url]
13
12
  [![tests][tests]][tests-url]
14
13
  [![coverage][cover]][cover-url]
15
14
  [![chat][chat]][chat-url]
@@ -43,11 +42,17 @@ pnpm add -D sass-loader sass webpack
43
42
 
44
43
  This allows you to control the versions of all your dependencies, and to choose which Sass implementation to use.
45
44
 
46
- > ℹ️ We highly recommend using [Dart Sass](https://github.com/sass/dart-sass).
45
+ > **Note**
46
+ >
47
+ > We highly recommend using [Dart Sass](https://github.com/sass/dart-sass).
47
48
 
48
- > ⚠ [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).
49
+ > **Warning**
50
+ >
51
+ > [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).
49
52
 
50
- > ⚠ [Sass Embedded](https://github.com/sass/embedded-host-node) is experimental and in `beta`, therefore some features may not work
53
+ > **Warning**
54
+ >
55
+ > [Sass Embedded](https://github.com/sass/embedded-host-node) is experimental and in `beta`, therefore some features may not work
51
56
 
52
57
  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.
53
58
 
@@ -245,7 +250,9 @@ To avoid this overhead, you can use the [fibers](https://www.npmjs.com/package/f
245
250
 
246
251
  We automatically inject the [`fibers`](https://github.com/laverdet/node-fibers) package (setup `sassOptions.fiber`) for `Node.js` less v16.0.0 if is possible (i.e. you need install the [`fibers`](https://github.com/laverdet/node-fibers) package).
247
252
 
248
- > Fibers is not compatible with `Node.js` v16.0.0 or later ([see introduction to readme](https://github.com/laverdet/node-fibers)).
253
+ > **Warning**
254
+ >
255
+ > Fibers is not compatible with `Node.js` v16.0.0 or later. Unfortunately, v8 commit [dacc2fee0f](https://github.com/v8/v8/commit/dacc2fee0f815823782a7e432c79c2a7767a4765) is a breaking change and workarounds are non-trivial. ([see introduction to readme](https://github.com/laverdet/node-fibers)).
249
256
 
250
257
  **package.json**
251
258
 
@@ -335,21 +342,29 @@ Default: defaults values for Sass implementation
335
342
 
336
343
  Options for [Dart Sass](http://sass-lang.com/dart-sass) or [Node Sass](https://github.com/sass/node-sass) implementation.
337
344
 
338
- > ℹ️ 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`.
345
+ > **Note**
346
+ >
347
+ > 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`.
339
348
 
340
- > ℹ️ The `indentedSyntax` option has `true` value for the `sass` extension.
349
+ > **Note**
350
+ >
351
+ > The `indentedSyntax` option has `true` value for the `sass` extension.
341
352
 
342
- > ℹ️ Options such as `data` and `file` are unavailable and will be ignored.
353
+ > **Note**
354
+ >
355
+ > Options such as `data` and `file` are unavailable and will be ignored.
343
356
 
344
357
  > ℹ We strongly discourage change `outFile`, `sourceMapContents`, `sourceMapEmbed`, `sourceMapRoot` options because `sass-loader` automatically sets these options when the `sourceMap` option is `true`.
345
358
 
346
- > ℹ️ 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.
359
+ > **Note**
360
+ >
361
+ > 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.
347
362
 
348
363
  There is a slight difference between the `sass` (`dart-sass`) and `node-sass` options.
349
364
 
350
365
  Please consult documentation before using them:
351
366
 
352
- - [Dart Sass documentation](https://github.com/sass/dart-sass#javascript-api) for all available `sass` options.
367
+ - [Dart Sass documentation](https://sass-lang.com/documentation/js-api/interfaces/Options) for all available `sass` options.
353
368
  - [Node Sass documentation](https://github.com/sass/node-sass/#options) for all available `node-sass` options.
354
369
 
355
370
  #### `object`
@@ -662,7 +677,9 @@ Default: `false`
662
677
 
663
678
  Treats the `@warn` rule as a webpack warning.
664
679
 
665
- > ℹ️ It will be `true` by default in the next major release.
680
+ > **Note**
681
+ >
682
+ > It will be `true` by default in the next major release.
666
683
 
667
684
  **style.scss**
668
685
 
@@ -726,9 +743,13 @@ Default: `"legacy"`
726
743
 
727
744
  Allows you to switch between `legacy` and `modern` API. You can find more information [here](https://sass-lang.com/documentation/js-api).
728
745
 
729
- > ⚠ "modern" API is experimental, so some features may not work (known: built-in `importer` is not working and files with errors is not watching on initial run), you can follow this [here](https://github.com/webpack-contrib/sass-loader/issues/774).
746
+ > **Warning**
747
+ >
748
+ > "modern" API is experimental, so some features may not work (known: built-in `importer` is not working and files with errors is not watching on initial run), you can follow this [here](https://github.com/webpack-contrib/sass-loader/issues/774).
730
749
 
731
- > ⚠ 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.
750
+ > **Warning**
751
+ >
752
+ > 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.
732
753
 
733
754
  **webpack.config.js**
734
755
 
@@ -757,6 +778,20 @@ module.exports = {
757
778
  };
758
779
  ```
759
780
 
781
+ ## How to enable `@debug` output
782
+
783
+ Defaults, the output of `@debug` messages is disabled.
784
+ To enable it, add to **webpack.config.js** following:
785
+
786
+ ```js
787
+ module.exports = {
788
+ stats: {
789
+ loggingDebug: ["sass-loader"],
790
+ },
791
+ // ...
792
+ };
793
+ ```
794
+
760
795
  ## Examples
761
796
 
762
797
  ### Extracts CSS into separate files
@@ -852,8 +887,6 @@ Please take a moment to read our contributing guidelines if you haven't yet done
852
887
  [npm-url]: https://npmjs.com/package/sass-loader
853
888
  [node]: https://img.shields.io/node/v/sass-loader.svg
854
889
  [node-url]: https://nodejs.org
855
- [deps]: https://david-dm.org/webpack-contrib/sass-loader.svg
856
- [deps-url]: https://david-dm.org/webpack-contrib/sass-loader
857
890
  [tests]: https://github.com/webpack-contrib/sass-loader/workflows/sass-loader/badge.svg
858
891
  [tests-url]: https://github.com/webpack-contrib/sass-loader/actions
859
892
  [cover]: https://codecov.io/gh/webpack-contrib/sass-loader/branch/master/graph/badge.svg
package/dist/SassError.js CHANGED
@@ -8,9 +8,7 @@ exports.default = void 0;
8
8
  class SassError extends Error {
9
9
  constructor(sassError) {
10
10
  super();
11
- this.name = "SassError"; // TODO remove me in the next major release
12
-
13
- this.originalSassError = sassError;
11
+ this.name = "SassError";
14
12
 
15
13
  if (typeof sassError.line !== "undefined" || typeof sassError.column !== "undefined") {
16
14
  this.loc = {
@@ -20,10 +18,10 @@ class SassError extends Error {
20
18
  } // Keep original error if `sassError.formatted` is unavailable
21
19
 
22
20
 
23
- this.message = `${this.name}: ${typeof this.originalSassError.message !== "undefined" ? this.originalSassError.message : this.originalSassError}`;
21
+ this.message = `${this.name}: ${typeof sassError.message !== "undefined" ? sassError.message : sassError}`;
24
22
 
25
- if (this.originalSassError.formatted) {
26
- this.message = `${this.name}: ${this.originalSassError.formatted.replace(/^Error: /, "")}`; // Instruct webpack to hide the JS stack from the console.
23
+ if (sassError.formatted) {
24
+ this.message = `${this.name}: ${sassError.formatted.replace(/^Error: /, "")}`; // Instruct webpack to hide the JS stack from the console.
27
25
  // Usually you're only interested in the SASS stack in this case.
28
26
 
29
27
  this.hideStack = true;
package/dist/utils.js CHANGED
@@ -29,13 +29,19 @@ function getDefaultSassImplementation() {
29
29
 
30
30
  try {
31
31
  require.resolve("sass");
32
- } catch (error) {
32
+ } catch (ignoreError) {
33
33
  try {
34
34
  require.resolve("node-sass");
35
35
 
36
36
  sassImplPkg = "node-sass";
37
- } catch (ignoreError) {
38
- sassImplPkg = "sass";
37
+ } catch (_ignoreError) {
38
+ try {
39
+ require.resolve("sass-embedded");
40
+
41
+ sassImplPkg = "sass-embedded";
42
+ } catch (__ignoreError) {
43
+ sassImplPkg = "sass";
44
+ }
39
45
  }
40
46
  } // eslint-disable-next-line import/no-dynamic-require, global-require
41
47
 
@@ -143,18 +149,19 @@ async function getSassOptions(loaderContext, loaderOptions, content, implementat
143
149
  options.data = loaderOptions.additionalData ? typeof loaderOptions.additionalData === "function" ? await loaderOptions.additionalData(content, loaderContext) : `${loaderOptions.additionalData}\n${content}` : content;
144
150
 
145
151
  if (!options.logger) {
146
- // TODO set me to `true` by default in the next major release
147
- const needEmitWarning = loaderOptions.warnRuleAsWarning === true;
152
+ const needEmitWarning = loaderOptions.warnRuleAsWarning !== false;
148
153
  const logger = loaderContext.getLogger("sass-loader");
149
154
 
150
155
  const formatSpan = span => `${span.url || "-"}:${span.start.line}:${span.start.column}: `;
151
156
 
157
+ const formatDebugSpan = span => `[debug:${span.start.line}:${span.start.column}] `;
158
+
152
159
  options.logger = {
153
160
  debug(message, loggerOptions) {
154
161
  let builtMessage = "";
155
162
 
156
163
  if (loggerOptions.span) {
157
- builtMessage = formatSpan(loggerOptions.span);
164
+ builtMessage = formatDebugSpan(loggerOptions.span);
158
165
  }
159
166
 
160
167
  builtMessage += message;
@@ -216,7 +223,7 @@ async function getSassOptions(loaderContext, loaderOptions, content, implementat
216
223
  }
217
224
  }
218
225
 
219
- options.importers = options.importers ? proxyCustomImporters(Array.isArray(options.importers) ? options.importers : [options.importers], loaderContext) : [];
226
+ options.importers = options.importers ? Array.isArray(options.importers) ? options.importers : [options.importers] : [];
220
227
  } else {
221
228
  options.file = resourcePath;
222
229
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sass-loader",
3
- "version": "12.5.0",
3
+ "version": "13.0.1",
4
4
  "description": "Sass loader for webpack",
5
5
  "license": "MIT",
6
6
  "repository": "webpack-contrib/sass-loader",
@@ -13,7 +13,7 @@
13
13
  },
14
14
  "main": "dist/cjs.js",
15
15
  "engines": {
16
- "node": ">= 12.13.0"
16
+ "node": ">= 14.15.0"
17
17
  },
18
18
  "scripts": {
19
19
  "start": "npm run build -- -w",
@@ -63,43 +63,43 @@
63
63
  "neo-async": "^2.6.2"
64
64
  },
65
65
  "devDependencies": {
66
- "@babel/cli": "^7.17.0",
67
- "@babel/core": "^7.17.0",
68
- "@babel/preset-env": "^7.16.11",
69
- "@commitlint/cli": "^16.2.1",
70
- "@commitlint/config-conventional": "^16.2.1",
66
+ "@babel/cli": "^7.17.10",
67
+ "@babel/core": "^7.18.2",
68
+ "@babel/preset-env": "^7.18.2",
69
+ "@commitlint/cli": "^17.0.2",
70
+ "@commitlint/config-conventional": "^17.0.2",
71
71
  "@webpack-contrib/eslint-config-webpack": "^3.0.0",
72
- "babel-jest": "^27.5.0",
72
+ "babel-jest": "^28.1.0",
73
73
  "bootstrap-sass": "^3.4.1",
74
74
  "bootstrap-v4": "npm:bootstrap@^4.5.3",
75
75
  "bootstrap-v5": "npm:bootstrap@^5.0.1",
76
76
  "cross-env": "^7.0.3",
77
77
  "css-loader": "^6.6.0",
78
- "del": "^6.0.0",
78
+ "del": "^6.1.1",
79
79
  "del-cli": "^4.0.1",
80
80
  "enhanced-resolve": "^5.8.2",
81
- "eslint": "^8.8.0",
81
+ "eslint": "^8.16.0",
82
82
  "eslint-config-prettier": "^8.3.0",
83
83
  "eslint-plugin-import": "^2.25.4",
84
84
  "fibers": "^5.0.1",
85
85
  "file-loader": "^6.2.0",
86
86
  "foundation-sites": "^6.6.3",
87
- "husky": "^7.0.1",
88
- "jest": "^27.5.0",
89
- "jest-environment-node-single-context": "^27.2.0",
90
- "lint-staged": "^12.3.3",
87
+ "husky": "^8.0.1",
88
+ "jest": "^28.1.0",
89
+ "jest-environment-node-single-context": "^28.0.0",
90
+ "lint-staged": "^12.5.0",
91
91
  "material-components-web": "^8.0.0",
92
- "memfs": "^3.4.1",
92
+ "memfs": "^3.4.4",
93
93
  "node-sass": "^7.0.1",
94
94
  "node-sass-glob-importer": "^5.3.2",
95
95
  "npm-run-all": "^4.1.5",
96
96
  "prettier": "^2.3.2",
97
- "sass": "^1.49.7",
98
- "sass-embedded": "^1.49.7",
97
+ "sass": "^1.52.1",
98
+ "sass-embedded": "^1.52.1",
99
99
  "semver": "^7.3.5",
100
100
  "standard-version": "^9.3.1",
101
101
  "style-loader": "^3.2.1",
102
- "webpack": "^5.68.0"
102
+ "webpack": "^5.73.0"
103
103
  },
104
104
  "keywords": [
105
105
  "sass",