sass-loader 13.3.1 → 13.3.2

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.
Files changed (3) hide show
  1. package/README.md +4 -0
  2. package/dist/utils.js +44 -40
  3. package/package.json +1 -2
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/).
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
116
  const formatSpan = span => `${span.url || "-"}:${span.start.line}:${span.start.column}: `;
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) {
@@ -148,36 +147,38 @@ async function getSassOptions(loaderContext, loaderOptions, content, implementat
148
147
  }
149
148
  };
150
149
  }
150
+ const isModernAPI = loaderOptions.api === "modern";
151
151
  const {
152
152
  resourcePath
153
153
  } = loaderContext;
154
154
  if (isModernAPI) {
155
- options.url = _url.default.pathToFileURL(resourcePath);
155
+ sassOptions.url = _url.default.pathToFileURL(resourcePath);
156
156
 
157
157
  // opt.outputStyle
158
- if (!options.style && isProductionLikeMode(loaderContext)) {
159
- options.style = "compressed";
158
+ if (!sassOptions.style && isProductionLikeMode(loaderContext)) {
159
+ sassOptions.style = "compressed";
160
160
  }
161
161
  if (useSourceMap) {
162
- options.sourceMap = true;
162
+ sassOptions.sourceMap = true;
163
163
  }
164
164
 
165
165
  // If we are compiling sass and indentedSyntax isn't set, automatically set it.
166
- if (typeof options.syntax === "undefined") {
166
+ if (typeof sassOptions.syntax === "undefined") {
167
167
  const ext = _path.default.extname(resourcePath);
168
168
  if (ext && ext.toLowerCase() === ".scss") {
169
- options.syntax = "scss";
169
+ sassOptions.syntax = "scss";
170
170
  } else if (ext && ext.toLowerCase() === ".sass") {
171
- options.syntax = "indented";
171
+ sassOptions.syntax = "indented";
172
172
  } else if (ext && ext.toLowerCase() === ".css") {
173
- options.syntax = "css";
173
+ sassOptions.syntax = "css";
174
174
  }
175
175
  }
176
- options.importers = options.importers ? Array.isArray(options.importers) ? options.importers : [options.importers] : [];
176
+ sassOptions.importers = sassOptions.importers ? Array.isArray(sassOptions.importers) ? sassOptions.importers.slice() : [sassOptions.importers] : [];
177
177
  } else {
178
- options.file = resourcePath;
178
+ sassOptions.file = resourcePath;
179
+ const isDartSass = implementation.info.includes("dart-sass");
179
180
  if (isDartSass && isSupportedFibers()) {
180
- const shouldTryToResolveFibers = !options.fiber && options.fiber !== false;
181
+ const shouldTryToResolveFibers = !sassOptions.fiber && sassOptions.fiber !== false;
181
182
  if (shouldTryToResolveFibers) {
182
183
  let fibers;
183
184
  try {
@@ -187,20 +188,20 @@ async function getSassOptions(loaderContext, loaderOptions, content, implementat
187
188
  }
188
189
  if (fibers) {
189
190
  // eslint-disable-next-line global-require, import/no-dynamic-require
190
- options.fiber = require(fibers);
191
+ sassOptions.fiber = require(fibers);
191
192
  }
192
- } else if (options.fiber === false) {
193
+ } else if (sassOptions.fiber === false) {
193
194
  // Don't pass the `fiber` option for `sass` (`Dart Sass`)
194
- delete options.fiber;
195
+ delete sassOptions.fiber;
195
196
  }
196
197
  } else {
197
198
  // Don't pass the `fiber` option for `node-sass`
198
- delete options.fiber;
199
+ delete sassOptions.fiber;
199
200
  }
200
201
 
201
202
  // opt.outputStyle
202
- if (!options.outputStyle && isProductionLikeMode(loaderContext)) {
203
- options.outputStyle = "compressed";
203
+ if (!sassOptions.outputStyle && isProductionLikeMode(loaderContext)) {
204
+ sassOptions.outputStyle = "compressed";
204
205
  }
205
206
  if (useSourceMap) {
206
207
  // Deliberately overriding the sourceMap option here.
@@ -209,31 +210,31 @@ async function getSassOptions(loaderContext, loaderOptions, content, implementat
209
210
  // But since we're using the data option, the source map will not actually be written, but
210
211
  // all paths in sourceMap.sources will be relative to that path.
211
212
  // 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;
213
+ sassOptions.sourceMap = true;
214
+ sassOptions.outFile = _path.default.join(loaderContext.rootContext, "style.css.map");
215
+ sassOptions.sourceMapContents = true;
216
+ sassOptions.omitSourceMapUrl = true;
217
+ sassOptions.sourceMapEmbed = false;
217
218
  }
218
219
  const ext = _path.default.extname(resourcePath);
219
220
 
220
221
  // 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;
222
+ if (ext && ext.toLowerCase() === ".sass" && typeof sassOptions.indentedSyntax === "undefined") {
223
+ sassOptions.indentedSyntax = true;
223
224
  } else {
224
- options.indentedSyntax = Boolean(options.indentedSyntax);
225
+ sassOptions.indentedSyntax = Boolean(sassOptions.indentedSyntax);
225
226
  }
226
227
 
227
228
  // 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(
229
+ sassOptions.importer = sassOptions.importer ? proxyCustomImporters(Array.isArray(sassOptions.importer) ? sassOptions.importer.slice() : [sassOptions.importer], loaderContext) : [];
230
+ sassOptions.includePaths = [].concat(process.cwd()).concat(
230
231
  // 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;
232
+ (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" ? ";" : ":") : []);
233
+ if (typeof sassOptions.charset === "undefined") {
234
+ sassOptions.charset = true;
234
235
  }
235
236
  }
236
- return options;
237
+ return sassOptions;
237
238
  }
238
239
  const MODULE_REQUEST_REGEX = /^[^?]*~/;
239
240
 
@@ -553,7 +554,10 @@ function getCompileFn(implementation, options) {
553
554
  // We need to use a job queue to make sure that one thread is always available to the UV lib
554
555
  if (nodeSassJobQueue === null) {
555
556
  const threadPoolSize = Number(process.env.UV_THREADPOOL_SIZE || 4);
556
- nodeSassJobQueue = _neoAsync.default.queue(implementation.render.bind(implementation), threadPoolSize - 1);
557
+ // Only used for `node-sass`, so let's load it lazily
558
+ // eslint-disable-next-line global-require
559
+ const async = require("neo-async");
560
+ nodeSassJobQueue = async.queue(implementation.render.bind(implementation), threadPoolSize - 1);
557
561
  }
558
562
  return sassOptions => new Promise((resolve, reject) => {
559
563
  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.2",
4
4
  "description": "Sass loader for webpack",
5
5
  "license": "MIT",
6
6
  "repository": "webpack-contrib/sass-loader",
@@ -63,7 +63,6 @@
63
63
  }
64
64
  },
65
65
  "dependencies": {
66
- "klona": "^2.0.6",
67
66
  "neo-async": "^2.6.2"
68
67
  },
69
68
  "devDependencies": {