sass-loader 13.3.2 → 14.0.0
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 +3 -86
- package/dist/index.js +2 -3
- package/dist/utils.js +13 -31
- package/package.json +26 -31
package/README.md
CHANGED
|
@@ -249,85 +249,6 @@ module.exports = {
|
|
|
249
249
|
};
|
|
250
250
|
```
|
|
251
251
|
|
|
252
|
-
Note that when using `sass` (`Dart Sass`), **synchronous compilation is twice as fast as asynchronous compilation** by default, due to the overhead of asynchronous callbacks.
|
|
253
|
-
To avoid this overhead, you can use the [fibers](https://www.npmjs.com/package/fibers) package to call asynchronous importers from the synchronous code path.
|
|
254
|
-
|
|
255
|
-
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).
|
|
256
|
-
|
|
257
|
-
> **Warning**
|
|
258
|
-
>
|
|
259
|
-
> 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)).
|
|
260
|
-
|
|
261
|
-
**package.json**
|
|
262
|
-
|
|
263
|
-
```json
|
|
264
|
-
{
|
|
265
|
-
"devDependencies": {
|
|
266
|
-
"sass-loader": "^7.2.0",
|
|
267
|
-
"sass": "^1.22.10",
|
|
268
|
-
"fibers": "^4.0.1"
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
```
|
|
272
|
-
|
|
273
|
-
You can disable automatically injecting the [`fibers`](https://github.com/laverdet/node-fibers) package by passing a `false` value for the `sassOptions.fiber` option.
|
|
274
|
-
|
|
275
|
-
**webpack.config.js**
|
|
276
|
-
|
|
277
|
-
```js
|
|
278
|
-
module.exports = {
|
|
279
|
-
module: {
|
|
280
|
-
rules: [
|
|
281
|
-
{
|
|
282
|
-
test: /\.s[ac]ss$/i,
|
|
283
|
-
use: [
|
|
284
|
-
"style-loader",
|
|
285
|
-
"css-loader",
|
|
286
|
-
{
|
|
287
|
-
loader: "sass-loader",
|
|
288
|
-
options: {
|
|
289
|
-
implementation: require("sass"),
|
|
290
|
-
sassOptions: {
|
|
291
|
-
fiber: false,
|
|
292
|
-
},
|
|
293
|
-
},
|
|
294
|
-
},
|
|
295
|
-
],
|
|
296
|
-
},
|
|
297
|
-
],
|
|
298
|
-
},
|
|
299
|
-
};
|
|
300
|
-
```
|
|
301
|
-
|
|
302
|
-
You can also pass the `fiber` value using this code:
|
|
303
|
-
|
|
304
|
-
**webpack.config.js**
|
|
305
|
-
|
|
306
|
-
```js
|
|
307
|
-
module.exports = {
|
|
308
|
-
module: {
|
|
309
|
-
rules: [
|
|
310
|
-
{
|
|
311
|
-
test: /\.s[ac]ss$/i,
|
|
312
|
-
use: [
|
|
313
|
-
"style-loader",
|
|
314
|
-
"css-loader",
|
|
315
|
-
{
|
|
316
|
-
loader: "sass-loader",
|
|
317
|
-
options: {
|
|
318
|
-
implementation: require("sass"),
|
|
319
|
-
sassOptions: {
|
|
320
|
-
fiber: require("fibers"),
|
|
321
|
-
},
|
|
322
|
-
},
|
|
323
|
-
},
|
|
324
|
-
],
|
|
325
|
-
},
|
|
326
|
-
],
|
|
327
|
-
},
|
|
328
|
-
};
|
|
329
|
-
```
|
|
330
|
-
|
|
331
252
|
### `sassOptions`
|
|
332
253
|
|
|
333
254
|
Type:
|
|
@@ -338,7 +259,7 @@ type sassOptions =
|
|
|
338
259
|
| ((
|
|
339
260
|
content: string | Buffer,
|
|
340
261
|
loaderContext: LoaderContext,
|
|
341
|
-
meta: any
|
|
262
|
+
meta: any,
|
|
342
263
|
) => import("sass").LegacyOptions<"async">);
|
|
343
264
|
```
|
|
344
265
|
|
|
@@ -418,7 +339,7 @@ module.exports = {
|
|
|
418
339
|
{
|
|
419
340
|
loader: "sass-loader",
|
|
420
341
|
options: {
|
|
421
|
-
sassOptions: (loaderContext) => {
|
|
342
|
+
sassOptions: (content, loaderContext) => {
|
|
422
343
|
// More information about available properties https://webpack.js.org/api/loaders/
|
|
423
344
|
const { resourcePath, rootContext } = loaderContext;
|
|
424
345
|
const relativePath = path.relative(rootContext, resourcePath);
|
|
@@ -677,14 +598,10 @@ Type:
|
|
|
677
598
|
type warnRuleAsWarning = boolean;
|
|
678
599
|
```
|
|
679
600
|
|
|
680
|
-
Default: `
|
|
601
|
+
Default: `true`
|
|
681
602
|
|
|
682
603
|
Treats the `@warn` rule as a webpack warning.
|
|
683
604
|
|
|
684
|
-
> **Note**
|
|
685
|
-
>
|
|
686
|
-
> It will be `true` by default in the next major release.
|
|
687
|
-
|
|
688
605
|
**style.scss**
|
|
689
606
|
|
|
690
607
|
```scss
|
package/dist/index.js
CHANGED
|
@@ -74,7 +74,7 @@ async function loader(content) {
|
|
|
74
74
|
|
|
75
75
|
// Modern API
|
|
76
76
|
if (typeof result.loadedUrls !== "undefined") {
|
|
77
|
-
result.loadedUrls.filter(
|
|
77
|
+
result.loadedUrls.filter(loadedUrl => loadedUrl.protocol === "file:").forEach(includedFile => {
|
|
78
78
|
const normalizedIncludedFile = _url.default.fileURLToPath(includedFile);
|
|
79
79
|
|
|
80
80
|
// Custom `importer` can return only `contents` so includedFile will be relative
|
|
@@ -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
|
@@ -10,7 +10,6 @@ exports.getSassImplementation = getSassImplementation;
|
|
|
10
10
|
exports.getSassOptions = getSassOptions;
|
|
11
11
|
exports.getWebpackImporter = getWebpackImporter;
|
|
12
12
|
exports.getWebpackResolver = getWebpackResolver;
|
|
13
|
-
exports.isSupportedFibers = isSupportedFibers;
|
|
14
13
|
exports.normalizeSourceMap = normalizeSourceMap;
|
|
15
14
|
var _url = _interopRequireDefault(require("url"));
|
|
16
15
|
var _path = _interopRequireDefault(require("path"));
|
|
@@ -89,10 +88,6 @@ function proxyCustomImporters(importers, loaderContext) {
|
|
|
89
88
|
return importer.apply(self, args);
|
|
90
89
|
});
|
|
91
90
|
}
|
|
92
|
-
function isSupportedFibers() {
|
|
93
|
-
const [nodeVersion] = process.versions.node.split(".");
|
|
94
|
-
return Number(nodeVersion) < 16;
|
|
95
|
-
}
|
|
96
91
|
|
|
97
92
|
/**
|
|
98
93
|
* Derives the sass options from the loader context and normalizes its values with sane defaults.
|
|
@@ -113,7 +108,7 @@ async function getSassOptions(loaderContext, loaderOptions, content, implementat
|
|
|
113
108
|
if (!sassOptions.logger) {
|
|
114
109
|
const needEmitWarning = loaderOptions.warnRuleAsWarning !== false;
|
|
115
110
|
const logger = loaderContext.getLogger("sass-loader");
|
|
116
|
-
const formatSpan = span =>
|
|
111
|
+
const formatSpan = span => `Warning on line ${span.start.line}, column ${span.start.column} of ${span.url || "-"}:${span.start.line}:${span.start.column}:\n`;
|
|
117
112
|
const formatDebugSpan = span => `[debug:${span.start.line}:${span.start.column}] `;
|
|
118
113
|
sassOptions.logger = {
|
|
119
114
|
debug(message, loggerOptions) {
|
|
@@ -129,11 +124,14 @@ async function getSassOptions(loaderContext, loaderOptions, content, implementat
|
|
|
129
124
|
if (loggerOptions.deprecation) {
|
|
130
125
|
builtMessage += "Deprecation ";
|
|
131
126
|
}
|
|
132
|
-
if (loggerOptions.span
|
|
133
|
-
builtMessage
|
|
127
|
+
if (loggerOptions.span) {
|
|
128
|
+
builtMessage += formatSpan(loggerOptions.span);
|
|
134
129
|
}
|
|
135
130
|
builtMessage += message;
|
|
136
|
-
if (loggerOptions.
|
|
131
|
+
if (loggerOptions.span && loggerOptions.span.context) {
|
|
132
|
+
builtMessage += `\n\n${loggerOptions.span.start.line} | ${loggerOptions.span.context}`;
|
|
133
|
+
}
|
|
134
|
+
if (loggerOptions.stack && loggerOptions.stack !== "null") {
|
|
137
135
|
builtMessage += `\n\n${loggerOptions.stack}`;
|
|
138
136
|
}
|
|
139
137
|
if (needEmitWarning) {
|
|
@@ -176,28 +174,6 @@ async function getSassOptions(loaderContext, loaderOptions, content, implementat
|
|
|
176
174
|
sassOptions.importers = sassOptions.importers ? Array.isArray(sassOptions.importers) ? sassOptions.importers.slice() : [sassOptions.importers] : [];
|
|
177
175
|
} else {
|
|
178
176
|
sassOptions.file = resourcePath;
|
|
179
|
-
const isDartSass = implementation.info.includes("dart-sass");
|
|
180
|
-
if (isDartSass && isSupportedFibers()) {
|
|
181
|
-
const shouldTryToResolveFibers = !sassOptions.fiber && sassOptions.fiber !== false;
|
|
182
|
-
if (shouldTryToResolveFibers) {
|
|
183
|
-
let fibers;
|
|
184
|
-
try {
|
|
185
|
-
fibers = require.resolve("fibers");
|
|
186
|
-
} catch (_error) {
|
|
187
|
-
// Nothing
|
|
188
|
-
}
|
|
189
|
-
if (fibers) {
|
|
190
|
-
// eslint-disable-next-line global-require, import/no-dynamic-require
|
|
191
|
-
sassOptions.fiber = require(fibers);
|
|
192
|
-
}
|
|
193
|
-
} else if (sassOptions.fiber === false) {
|
|
194
|
-
// Don't pass the `fiber` option for `sass` (`Dart Sass`)
|
|
195
|
-
delete sassOptions.fiber;
|
|
196
|
-
}
|
|
197
|
-
} else {
|
|
198
|
-
// Don't pass the `fiber` option for `node-sass`
|
|
199
|
-
delete sassOptions.fiber;
|
|
200
|
-
}
|
|
201
177
|
|
|
202
178
|
// opt.outputStyle
|
|
203
179
|
if (!sassOptions.outputStyle && isProductionLikeMode(loaderContext)) {
|
|
@@ -227,6 +203,12 @@ async function getSassOptions(loaderContext, loaderOptions, content, implementat
|
|
|
227
203
|
|
|
228
204
|
// Allow passing custom importers to `sass`/`node-sass`. Accepts `Function` or an array of `Function`s.
|
|
229
205
|
sassOptions.importer = sassOptions.importer ? proxyCustomImporters(Array.isArray(sassOptions.importer) ? sassOptions.importer.slice() : [sassOptions.importer], loaderContext) : [];
|
|
206
|
+
|
|
207
|
+
// Regression on the `sass-embedded` side
|
|
208
|
+
if (loaderOptions.webpackImporter === false && sassOptions.importer.length === 0) {
|
|
209
|
+
// eslint-disable-next-line no-undefined
|
|
210
|
+
sassOptions.importer = undefined;
|
|
211
|
+
}
|
|
230
212
|
sassOptions.includePaths = [].concat(process.cwd()).concat(
|
|
231
213
|
// We use `includePaths` in context for resolver, so it should be always absolute
|
|
232
214
|
(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" ? ";" : ":") : []);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sass-loader",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "14.0.0",
|
|
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": ">=
|
|
16
|
+
"node": ">= 18.12.0"
|
|
17
17
|
},
|
|
18
18
|
"scripts": {
|
|
19
19
|
"start": "npm run build -- -w",
|
|
@@ -42,7 +42,6 @@
|
|
|
42
42
|
"dist"
|
|
43
43
|
],
|
|
44
44
|
"peerDependencies": {
|
|
45
|
-
"fibers": ">= 3.1.0",
|
|
46
45
|
"node-sass": "^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0 || ^9.0.0",
|
|
47
46
|
"sass": "^1.3.0",
|
|
48
47
|
"sass-embedded": "*",
|
|
@@ -57,53 +56,49 @@
|
|
|
57
56
|
},
|
|
58
57
|
"sass-embedded": {
|
|
59
58
|
"optional": true
|
|
60
|
-
},
|
|
61
|
-
"fibers": {
|
|
62
|
-
"optional": true
|
|
63
59
|
}
|
|
64
60
|
},
|
|
65
61
|
"dependencies": {
|
|
66
62
|
"neo-async": "^2.6.2"
|
|
67
63
|
},
|
|
68
64
|
"devDependencies": {
|
|
69
|
-
"@babel/cli": "^7.
|
|
70
|
-
"@babel/core": "^7.
|
|
71
|
-
"@babel/preset-env": "^7.
|
|
72
|
-
"@commitlint/cli": "^
|
|
73
|
-
"@commitlint/config-conventional": "^
|
|
65
|
+
"@babel/cli": "^7.23.4",
|
|
66
|
+
"@babel/core": "^7.23.7",
|
|
67
|
+
"@babel/preset-env": "^7.23.8",
|
|
68
|
+
"@commitlint/cli": "^18.4.4",
|
|
69
|
+
"@commitlint/config-conventional": "^18.4.4",
|
|
74
70
|
"@webpack-contrib/eslint-config-webpack": "^3.0.0",
|
|
75
|
-
"babel-jest": "^29.
|
|
71
|
+
"babel-jest": "^29.6.2",
|
|
76
72
|
"bootstrap-sass": "^3.4.1",
|
|
77
73
|
"bootstrap-v4": "npm:bootstrap@^4.5.3",
|
|
78
74
|
"bootstrap-v5": "npm:bootstrap@^5.0.1",
|
|
79
75
|
"cross-env": "^7.0.3",
|
|
80
|
-
"cspell": "^
|
|
81
|
-
"css-loader": "^6.
|
|
76
|
+
"cspell": "^8.3.2",
|
|
77
|
+
"css-loader": "^6.9.0",
|
|
82
78
|
"del": "^6.1.1",
|
|
83
|
-
"del-cli": "^
|
|
84
|
-
"enhanced-resolve": "^5.
|
|
85
|
-
"eslint": "^8.
|
|
86
|
-
"eslint-config-prettier": "^
|
|
87
|
-
"eslint-plugin-import": "^2.
|
|
88
|
-
"fibers": "^5.0.3",
|
|
79
|
+
"del-cli": "^5.1.0",
|
|
80
|
+
"enhanced-resolve": "^5.15.0",
|
|
81
|
+
"eslint": "^8.46.0",
|
|
82
|
+
"eslint-config-prettier": "^9.1.0",
|
|
83
|
+
"eslint-plugin-import": "^2.28.0",
|
|
89
84
|
"file-loader": "^6.2.0",
|
|
90
85
|
"foundation-sites": "^6.7.5",
|
|
91
86
|
"husky": "^8.0.3",
|
|
92
|
-
"jest": "^29.
|
|
93
|
-
"jest-environment-node-single-context": "^29.
|
|
94
|
-
"lint-staged": "^
|
|
87
|
+
"jest": "^29.6.2",
|
|
88
|
+
"jest-environment-node-single-context": "^29.1.0",
|
|
89
|
+
"lint-staged": "^15.2.0",
|
|
95
90
|
"material-components-web": "^9.0.0",
|
|
96
|
-
"memfs": "^
|
|
97
|
-
"node-sass": "^
|
|
91
|
+
"memfs": "^4.6.0",
|
|
92
|
+
"node-sass": "^9.0.0",
|
|
98
93
|
"node-sass-glob-importer": "^5.3.2",
|
|
99
94
|
"npm-run-all": "^4.1.5",
|
|
100
|
-
"prettier": "^2.
|
|
101
|
-
"sass": "^1.
|
|
102
|
-
"sass-embedded": "^1.
|
|
103
|
-
"semver": "^7.5.
|
|
95
|
+
"prettier": "^3.2.2",
|
|
96
|
+
"sass": "^1.69.7",
|
|
97
|
+
"sass-embedded": "^1.69.7",
|
|
98
|
+
"semver": "^7.5.4",
|
|
104
99
|
"standard-version": "^9.3.1",
|
|
105
|
-
"style-loader": "^3.3.
|
|
106
|
-
"webpack": "^5.
|
|
100
|
+
"style-loader": "^3.3.4",
|
|
101
|
+
"webpack": "^5.88.2"
|
|
107
102
|
},
|
|
108
103
|
"keywords": [
|
|
109
104
|
"sass",
|