sass-loader 13.3.1 → 13.3.3

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
@@ -98,6 +98,10 @@ module.exports = {
98
98
 
99
99
  Finally run `webpack` via your preferred method.
100
100
 
101
+ ### The `outputStyle` (old API) and `style` (new API) options in `production` mode
102
+
103
+ For `production` mode, the `outputStyle` (old API) and `style` (new API) options default to `compressed` unless otherwise specified in `sassOptions`.
104
+
101
105
  ### Resolving `import` at-rules
102
106
 
103
107
  Webpack provides an [advanced mechanism to resolve files](https://webpack.js.org/concepts/module-resolution/).
@@ -414,7 +418,7 @@ module.exports = {
414
418
  {
415
419
  loader: "sass-loader",
416
420
  options: {
417
- sassOptions: (loaderContext) => {
421
+ sassOptions: (content, loaderContext) => {
418
422
  // More information about available properties https://webpack.js.org/api/loaders/
419
423
  const { resourcePath, rootContext } = loaderContext;
420
424
  const relativePath = path.relative(rootContext, resourcePath);
@@ -673,14 +677,10 @@ Type:
673
677
  type warnRuleAsWarning = boolean;
674
678
  ```
675
679
 
676
- Default: `false`
680
+ Default: `true`
677
681
 
678
682
  Treats the `@warn` rule as a webpack warning.
679
683
 
680
- > **Note**
681
- >
682
- > It will be `true` by default in the next major release.
683
-
684
684
  **style.scss**
685
685
 
686
686
  ```scss
package/dist/index.js CHANGED
@@ -96,5 +96,4 @@ async function loader(content) {
96
96
  }
97
97
  callback(null, result.css.toString(), map);
98
98
  }
99
- var _default = loader;
100
- exports.default = _default;
99
+ var _default = exports.default = loader;
package/dist/utils.js CHANGED
@@ -14,8 +14,6 @@ exports.isSupportedFibers = isSupportedFibers;
14
14
  exports.normalizeSourceMap = normalizeSourceMap;
15
15
  var _url = _interopRequireDefault(require("url"));
16
16
  var _path = _interopRequireDefault(require("path"));
17
- var _full = require("klona/full");
18
- var _neoAsync = _interopRequireDefault(require("neo-async"));
19
17
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
18
  function getDefaultSassImplementation() {
21
19
  let sassImplPkg = "sass";
@@ -107,16 +105,17 @@ function isSupportedFibers() {
107
105
  * @returns {Object}
108
106
  */
109
107
  async function getSassOptions(loaderContext, loaderOptions, content, implementation, useSourceMap) {
110
- const options = (0, _full.klona)(loaderOptions.sassOptions ? typeof loaderOptions.sassOptions === "function" ? loaderOptions.sassOptions(loaderContext) || {} : loaderOptions.sassOptions : {});
111
- const isDartSass = implementation.info.includes("dart-sass");
112
- const isModernAPI = loaderOptions.api === "modern";
113
- options.data = loaderOptions.additionalData ? typeof loaderOptions.additionalData === "function" ? await loaderOptions.additionalData(content, loaderContext) : `${loaderOptions.additionalData}\n${content}` : content;
114
- if (!options.logger) {
108
+ const options = loaderOptions.sassOptions ? typeof loaderOptions.sassOptions === "function" ? loaderOptions.sassOptions(loaderContext) || {} : loaderOptions.sassOptions : {};
109
+ const sassOptions = {
110
+ ...options,
111
+ data: loaderOptions.additionalData ? typeof loaderOptions.additionalData === "function" ? await loaderOptions.additionalData(content, loaderContext) : `${loaderOptions.additionalData}\n${content}` : content
112
+ };
113
+ if (!sassOptions.logger) {
115
114
  const needEmitWarning = loaderOptions.warnRuleAsWarning !== false;
116
115
  const logger = loaderContext.getLogger("sass-loader");
117
- const formatSpan = span => `${span.url || "-"}:${span.start.line}:${span.start.column}: `;
116
+ const formatSpan = span => `Warning on line ${span.start.line}, column ${span.start.column} of ${span.url || "-"}:${span.start.line}:${span.start.column}:\n`;
118
117
  const formatDebugSpan = span => `[debug:${span.start.line}:${span.start.column}] `;
119
- options.logger = {
118
+ sassOptions.logger = {
120
119
  debug(message, loggerOptions) {
121
120
  let builtMessage = "";
122
121
  if (loggerOptions.span) {
@@ -130,11 +129,14 @@ async function getSassOptions(loaderContext, loaderOptions, content, implementat
130
129
  if (loggerOptions.deprecation) {
131
130
  builtMessage += "Deprecation ";
132
131
  }
133
- if (loggerOptions.span && !loggerOptions.stack) {
134
- builtMessage = formatSpan(loggerOptions.span);
132
+ if (loggerOptions.span) {
133
+ builtMessage += formatSpan(loggerOptions.span);
135
134
  }
136
135
  builtMessage += message;
137
- if (loggerOptions.stack) {
136
+ if (loggerOptions.span && loggerOptions.span.context) {
137
+ builtMessage += `\n\n${loggerOptions.span.start.line} | ${loggerOptions.span.context}`;
138
+ }
139
+ if (loggerOptions.stack && loggerOptions.stack !== "null") {
138
140
  builtMessage += `\n\n${loggerOptions.stack}`;
139
141
  }
140
142
  if (needEmitWarning) {
@@ -148,36 +150,38 @@ async function getSassOptions(loaderContext, loaderOptions, content, implementat
148
150
  }
149
151
  };
150
152
  }
153
+ const isModernAPI = loaderOptions.api === "modern";
151
154
  const {
152
155
  resourcePath
153
156
  } = loaderContext;
154
157
  if (isModernAPI) {
155
- options.url = _url.default.pathToFileURL(resourcePath);
158
+ sassOptions.url = _url.default.pathToFileURL(resourcePath);
156
159
 
157
160
  // opt.outputStyle
158
- if (!options.style && isProductionLikeMode(loaderContext)) {
159
- options.style = "compressed";
161
+ if (!sassOptions.style && isProductionLikeMode(loaderContext)) {
162
+ sassOptions.style = "compressed";
160
163
  }
161
164
  if (useSourceMap) {
162
- options.sourceMap = true;
165
+ sassOptions.sourceMap = true;
163
166
  }
164
167
 
165
168
  // If we are compiling sass and indentedSyntax isn't set, automatically set it.
166
- if (typeof options.syntax === "undefined") {
169
+ if (typeof sassOptions.syntax === "undefined") {
167
170
  const ext = _path.default.extname(resourcePath);
168
171
  if (ext && ext.toLowerCase() === ".scss") {
169
- options.syntax = "scss";
172
+ sassOptions.syntax = "scss";
170
173
  } else if (ext && ext.toLowerCase() === ".sass") {
171
- options.syntax = "indented";
174
+ sassOptions.syntax = "indented";
172
175
  } else if (ext && ext.toLowerCase() === ".css") {
173
- options.syntax = "css";
176
+ sassOptions.syntax = "css";
174
177
  }
175
178
  }
176
- options.importers = options.importers ? Array.isArray(options.importers) ? options.importers : [options.importers] : [];
179
+ sassOptions.importers = sassOptions.importers ? Array.isArray(sassOptions.importers) ? sassOptions.importers.slice() : [sassOptions.importers] : [];
177
180
  } else {
178
- options.file = resourcePath;
181
+ sassOptions.file = resourcePath;
182
+ const isDartSass = implementation.info.includes("dart-sass");
179
183
  if (isDartSass && isSupportedFibers()) {
180
- const shouldTryToResolveFibers = !options.fiber && options.fiber !== false;
184
+ const shouldTryToResolveFibers = !sassOptions.fiber && sassOptions.fiber !== false;
181
185
  if (shouldTryToResolveFibers) {
182
186
  let fibers;
183
187
  try {
@@ -187,20 +191,20 @@ async function getSassOptions(loaderContext, loaderOptions, content, implementat
187
191
  }
188
192
  if (fibers) {
189
193
  // eslint-disable-next-line global-require, import/no-dynamic-require
190
- options.fiber = require(fibers);
194
+ sassOptions.fiber = require(fibers);
191
195
  }
192
- } else if (options.fiber === false) {
196
+ } else if (sassOptions.fiber === false) {
193
197
  // Don't pass the `fiber` option for `sass` (`Dart Sass`)
194
- delete options.fiber;
198
+ delete sassOptions.fiber;
195
199
  }
196
200
  } else {
197
201
  // Don't pass the `fiber` option for `node-sass`
198
- delete options.fiber;
202
+ delete sassOptions.fiber;
199
203
  }
200
204
 
201
205
  // opt.outputStyle
202
- if (!options.outputStyle && isProductionLikeMode(loaderContext)) {
203
- options.outputStyle = "compressed";
206
+ if (!sassOptions.outputStyle && isProductionLikeMode(loaderContext)) {
207
+ sassOptions.outputStyle = "compressed";
204
208
  }
205
209
  if (useSourceMap) {
206
210
  // Deliberately overriding the sourceMap option here.
@@ -209,31 +213,36 @@ async function getSassOptions(loaderContext, loaderOptions, content, implementat
209
213
  // But since we're using the data option, the source map will not actually be written, but
210
214
  // all paths in sourceMap.sources will be relative to that path.
211
215
  // Pretty complicated... :(
212
- options.sourceMap = true;
213
- options.outFile = _path.default.join(loaderContext.rootContext, "style.css.map");
214
- options.sourceMapContents = true;
215
- options.omitSourceMapUrl = true;
216
- options.sourceMapEmbed = false;
216
+ sassOptions.sourceMap = true;
217
+ sassOptions.outFile = _path.default.join(loaderContext.rootContext, "style.css.map");
218
+ sassOptions.sourceMapContents = true;
219
+ sassOptions.omitSourceMapUrl = true;
220
+ sassOptions.sourceMapEmbed = false;
217
221
  }
218
222
  const ext = _path.default.extname(resourcePath);
219
223
 
220
224
  // If we are compiling sass and indentedSyntax isn't set, automatically set it.
221
- if (ext && ext.toLowerCase() === ".sass" && typeof options.indentedSyntax === "undefined") {
222
- options.indentedSyntax = true;
225
+ if (ext && ext.toLowerCase() === ".sass" && typeof sassOptions.indentedSyntax === "undefined") {
226
+ sassOptions.indentedSyntax = true;
223
227
  } else {
224
- options.indentedSyntax = Boolean(options.indentedSyntax);
228
+ sassOptions.indentedSyntax = Boolean(sassOptions.indentedSyntax);
225
229
  }
226
230
 
227
231
  // Allow passing custom importers to `sass`/`node-sass`. Accepts `Function` or an array of `Function`s.
228
- options.importer = options.importer ? proxyCustomImporters(Array.isArray(options.importer) ? options.importer : [options.importer], loaderContext) : [];
229
- options.includePaths = [].concat(process.cwd()).concat(
232
+ sassOptions.importer = sassOptions.importer ? proxyCustomImporters(Array.isArray(sassOptions.importer) ? sassOptions.importer.slice() : [sassOptions.importer], loaderContext) : [];
233
+
234
+ // Regression on the `sass-embedded` side
235
+ if (loaderOptions.webpackImporter === false && sassOptions.importer.length === 0) {
236
+ sassOptions.importer = undefined;
237
+ }
238
+ sassOptions.includePaths = [].concat(process.cwd()).concat(
230
239
  // We use `includePaths` in context for resolver, so it should be always absolute
231
- (options.includePaths || []).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" ? ";" : ":") : []);
232
- if (typeof options.charset === "undefined") {
233
- options.charset = true;
240
+ (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" ? ";" : ":") : []);
241
+ if (typeof sassOptions.charset === "undefined") {
242
+ sassOptions.charset = true;
234
243
  }
235
244
  }
236
- return options;
245
+ return sassOptions;
237
246
  }
238
247
  const MODULE_REQUEST_REGEX = /^[^?]*~/;
239
248
 
@@ -553,7 +562,10 @@ function getCompileFn(implementation, options) {
553
562
  // We need to use a job queue to make sure that one thread is always available to the UV lib
554
563
  if (nodeSassJobQueue === null) {
555
564
  const threadPoolSize = Number(process.env.UV_THREADPOOL_SIZE || 4);
556
- nodeSassJobQueue = _neoAsync.default.queue(implementation.render.bind(implementation), threadPoolSize - 1);
565
+ // Only used for `node-sass`, so let's load it lazily
566
+ // eslint-disable-next-line global-require
567
+ const async = require("neo-async");
568
+ nodeSassJobQueue = async.queue(implementation.render.bind(implementation), threadPoolSize - 1);
557
569
  }
558
570
  return sassOptions => new Promise((resolve, reject) => {
559
571
  nodeSassJobQueue.push.bind(nodeSassJobQueue)(sassOptions, (error, result) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sass-loader",
3
- "version": "13.3.1",
3
+ "version": "13.3.3",
4
4
  "description": "Sass loader for webpack",
5
5
  "license": "MIT",
6
6
  "repository": "webpack-contrib/sass-loader",
@@ -63,48 +63,46 @@
63
63
  }
64
64
  },
65
65
  "dependencies": {
66
- "klona": "^2.0.6",
67
66
  "neo-async": "^2.6.2"
68
67
  },
69
68
  "devDependencies": {
70
- "@babel/cli": "^7.21.5",
71
- "@babel/core": "^7.21.5",
72
- "@babel/preset-env": "^7.21.5",
73
- "@commitlint/cli": "^17.6.1",
74
- "@commitlint/config-conventional": "^17.6.1",
69
+ "@babel/cli": "^7.22.9",
70
+ "@babel/core": "^7.22.9",
71
+ "@babel/preset-env": "^7.22.9",
72
+ "@commitlint/cli": "^17.6.7",
73
+ "@commitlint/config-conventional": "^17.6.7",
75
74
  "@webpack-contrib/eslint-config-webpack": "^3.0.0",
76
- "babel-jest": "^29.5.0",
75
+ "babel-jest": "^29.6.2",
77
76
  "bootstrap-sass": "^3.4.1",
78
77
  "bootstrap-v4": "npm:bootstrap@^4.5.3",
79
78
  "bootstrap-v5": "npm:bootstrap@^5.0.1",
80
79
  "cross-env": "^7.0.3",
81
- "cspell": "^6.31.1",
82
- "css-loader": "^6.7.3",
80
+ "cspell": "^6.31.2",
81
+ "css-loader": "^6.8.1",
83
82
  "del": "^6.1.1",
84
83
  "del-cli": "^4.0.1",
85
- "enhanced-resolve": "^5.13.0",
86
- "eslint": "^8.39.0",
87
- "eslint-config-prettier": "^8.8.0",
88
- "eslint-plugin-import": "^2.27.5",
89
- "fibers": "^5.0.3",
84
+ "enhanced-resolve": "^5.15.0",
85
+ "eslint": "^8.46.0",
86
+ "eslint-config-prettier": "^8.9.0",
87
+ "eslint-plugin-import": "^2.28.0",
90
88
  "file-loader": "^6.2.0",
91
89
  "foundation-sites": "^6.7.5",
92
90
  "husky": "^8.0.3",
93
- "jest": "^29.5.0",
94
- "jest-environment-node-single-context": "^29.0.0",
95
- "lint-staged": "^13.2.2",
91
+ "jest": "^29.6.2",
92
+ "jest-environment-node-single-context": "^29.1.0",
93
+ "lint-staged": "^13.2.3",
96
94
  "material-components-web": "^9.0.0",
97
95
  "memfs": "^3.5.1",
98
96
  "node-sass": "^8.0.0",
99
97
  "node-sass-glob-importer": "^5.3.2",
100
98
  "npm-run-all": "^4.1.5",
101
99
  "prettier": "^2.8.8",
102
- "sass": "^1.62.1",
103
- "sass-embedded": "^1.62.0",
104
- "semver": "^7.5.0",
100
+ "sass": "^1.64.2",
101
+ "sass-embedded": "^1.64.2",
102
+ "semver": "^7.5.4",
105
103
  "standard-version": "^9.3.1",
106
- "style-loader": "^3.3.2",
107
- "webpack": "^5.81.0"
104
+ "style-loader": "^3.3.3",
105
+ "webpack": "^5.88.2"
108
106
  },
109
107
  "keywords": [
110
108
  "sass",