sass-loader 15.0.0 → 16.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 +3 -3
- package/dist/index.js +5 -3
- package/dist/utils.js +12 -11
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -362,7 +362,7 @@ module.exports = {
|
|
|
362
362
|
{
|
|
363
363
|
loader: "sass-loader",
|
|
364
364
|
options: {
|
|
365
|
-
sassOptions: (
|
|
365
|
+
sassOptions: (loaderContext) => {
|
|
366
366
|
// More information about available properties https://webpack.js.org/api/loaders/
|
|
367
367
|
const { resourcePath, rootContext } = loaderContext;
|
|
368
368
|
const relativePath = path.relative(rootContext, resourcePath);
|
|
@@ -683,7 +683,7 @@ Type:
|
|
|
683
683
|
type api = "legacy" | "modern" | "modern-compiler";
|
|
684
684
|
```
|
|
685
685
|
|
|
686
|
-
Default: `"legacy"`
|
|
686
|
+
Default: `"modern"` for `sass` (`dart-sass`) and `sass-embedded` or `"legacy"` for `node-sass`
|
|
687
687
|
|
|
688
688
|
Allows you to switch between the `legacy` and `modern` 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).
|
|
689
689
|
|
|
@@ -709,7 +709,7 @@ module.exports = {
|
|
|
709
709
|
{
|
|
710
710
|
loader: "sass-loader",
|
|
711
711
|
options: {
|
|
712
|
-
api: "modern",
|
|
712
|
+
api: "modern-compiler",
|
|
713
713
|
sassOptions: {
|
|
714
714
|
// Your sass options
|
|
715
715
|
},
|
package/dist/index.js
CHANGED
|
@@ -26,10 +26,12 @@ async function loader(content) {
|
|
|
26
26
|
return;
|
|
27
27
|
}
|
|
28
28
|
const useSourceMap = typeof options.sourceMap === "boolean" ? options.sourceMap : this.sourceMap;
|
|
29
|
-
|
|
29
|
+
// Use `legacy` for `node-sass` and `modern` for `dart-sass` and `sass-embedded`
|
|
30
|
+
const apiType = typeof implementation.compileStringAsync === "undefined" ? "legacy" : typeof options.api === "undefined" ? "modern" : options.api;
|
|
31
|
+
const sassOptions = await (0, _utils.getSassOptions)(this, options, content, implementation, useSourceMap, apiType);
|
|
30
32
|
const shouldUseWebpackImporter = typeof options.webpackImporter === "boolean" ? options.webpackImporter : true;
|
|
31
33
|
if (shouldUseWebpackImporter) {
|
|
32
|
-
const isModernAPI =
|
|
34
|
+
const isModernAPI = apiType === "modern" || apiType === "modern-compiler";
|
|
33
35
|
if (!isModernAPI) {
|
|
34
36
|
const {
|
|
35
37
|
includePaths
|
|
@@ -43,7 +45,7 @@ async function loader(content) {
|
|
|
43
45
|
}
|
|
44
46
|
let compile;
|
|
45
47
|
try {
|
|
46
|
-
compile = (0, _utils.getCompileFn)(this, implementation,
|
|
48
|
+
compile = (0, _utils.getCompileFn)(this, implementation, apiType);
|
|
47
49
|
} catch (error) {
|
|
48
50
|
callback(error);
|
|
49
51
|
return;
|
package/dist/utils.js
CHANGED
|
@@ -97,9 +97,10 @@ function proxyCustomImporters(importers, loaderContext) {
|
|
|
97
97
|
* @param {string} content
|
|
98
98
|
* @param {object} implementation
|
|
99
99
|
* @param {boolean} useSourceMap
|
|
100
|
+
* @param {"legacy" | "modern" | "modern-compiler"} apiType
|
|
100
101
|
* @returns {Object}
|
|
101
102
|
*/
|
|
102
|
-
async function getSassOptions(loaderContext, loaderOptions, content, implementation, useSourceMap) {
|
|
103
|
+
async function getSassOptions(loaderContext, loaderOptions, content, implementation, useSourceMap, apiType) {
|
|
103
104
|
const options = loaderOptions.sassOptions ? typeof loaderOptions.sassOptions === "function" ? loaderOptions.sassOptions(loaderContext) || {} : loaderOptions.sassOptions : {};
|
|
104
105
|
const sassOptions = {
|
|
105
106
|
...options,
|
|
@@ -145,7 +146,7 @@ async function getSassOptions(loaderContext, loaderOptions, content, implementat
|
|
|
145
146
|
}
|
|
146
147
|
};
|
|
147
148
|
}
|
|
148
|
-
const isModernAPI =
|
|
149
|
+
const isModernAPI = apiType === "modern" || apiType === "modern-compiler";
|
|
149
150
|
const {
|
|
150
151
|
resourcePath
|
|
151
152
|
} = loaderContext;
|
|
@@ -349,7 +350,7 @@ const IS_NATIVE_WIN32_PATH = /^[a-z]:[/\\]|^\\\\/i;
|
|
|
349
350
|
* @throws If a compatible Sass implementation cannot be found.
|
|
350
351
|
*/
|
|
351
352
|
function getWebpackResolver(resolverFactory, implementation, includePaths = []) {
|
|
352
|
-
const isModernSass = implementation &&
|
|
353
|
+
const isModernSass = implementation && typeof implementation.compileStringAsync !== "undefined";
|
|
353
354
|
// We only have one difference with the built-in sass resolution logic and out resolution logic:
|
|
354
355
|
// First, we look at the files starting with `_`, then without `_` (i.e. `_name.sass`, `_name.scss`, `_name.css`, `name.sass`, `name.scss`, `name.css`),
|
|
355
356
|
// although `sass` look together by extensions (i.e. `_name.sass`/`name.sass`/`_name.scss`/`name.scss`/`_name.css`/`name.css`).
|
|
@@ -518,7 +519,8 @@ function getModernWebpackImporter(loaderContext, implementation, loadPaths) {
|
|
|
518
519
|
});
|
|
519
520
|
return {
|
|
520
521
|
contents,
|
|
521
|
-
syntax
|
|
522
|
+
syntax,
|
|
523
|
+
sourceMapUrl: canonicalUrl
|
|
522
524
|
};
|
|
523
525
|
} catch (err) {
|
|
524
526
|
return null;
|
|
@@ -559,13 +561,12 @@ const sassModernCompilers = new WeakMap();
|
|
|
559
561
|
*
|
|
560
562
|
* @param {Object} loaderContext
|
|
561
563
|
* @param {Object} implementation
|
|
562
|
-
* @param {
|
|
564
|
+
* @param {"legacy" | "modern" | "modern-compiler"} apiType
|
|
563
565
|
* @returns {Function}
|
|
564
566
|
*/
|
|
565
|
-
function getCompileFn(loaderContext, implementation,
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
if (options.api === "modern") {
|
|
567
|
+
function getCompileFn(loaderContext, implementation, apiType) {
|
|
568
|
+
if (typeof implementation.compileStringAsync !== "undefined") {
|
|
569
|
+
if (apiType === "modern") {
|
|
569
570
|
return sassOptions => {
|
|
570
571
|
const {
|
|
571
572
|
data,
|
|
@@ -574,7 +575,7 @@ function getCompileFn(loaderContext, implementation, options) {
|
|
|
574
575
|
return implementation.compileStringAsync(data, rest);
|
|
575
576
|
};
|
|
576
577
|
}
|
|
577
|
-
if (
|
|
578
|
+
if (apiType === "modern-compiler") {
|
|
578
579
|
return async sassOptions => {
|
|
579
580
|
// eslint-disable-next-line no-underscore-dangle
|
|
580
581
|
const webpackCompiler = loaderContext._compiler;
|
|
@@ -615,7 +616,7 @@ function getCompileFn(loaderContext, implementation, options) {
|
|
|
615
616
|
});
|
|
616
617
|
});
|
|
617
618
|
}
|
|
618
|
-
if (
|
|
619
|
+
if (apiType === "modern" || apiType === "modern-compiler") {
|
|
619
620
|
throw new Error("Modern API is not supported for 'node-sass'");
|
|
620
621
|
}
|
|
621
622
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sass-loader",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "16.0.1",
|
|
4
4
|
"description": "Sass loader for webpack",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "webpack-contrib/sass-loader",
|
|
@@ -72,8 +72,8 @@
|
|
|
72
72
|
"@babel/cli": "^7.23.4",
|
|
73
73
|
"@babel/core": "^7.24.0",
|
|
74
74
|
"@babel/preset-env": "^7.24.0",
|
|
75
|
-
"@commitlint/cli": "^
|
|
76
|
-
"@commitlint/config-conventional": "^
|
|
75
|
+
"@commitlint/cli": "^19.3.0",
|
|
76
|
+
"@commitlint/config-conventional": "^19.2.2",
|
|
77
77
|
"@webpack-contrib/eslint-config-webpack": "^3.0.0",
|
|
78
78
|
"babel-jest": "^29.6.2",
|
|
79
79
|
"bootstrap-sass": "^3.4.1",
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
"eslint-plugin-import": "^2.28.0",
|
|
91
91
|
"file-loader": "^6.2.0",
|
|
92
92
|
"foundation-sites": "^6.7.5",
|
|
93
|
-
"husky": "^9.
|
|
93
|
+
"husky": "^9.1.3",
|
|
94
94
|
"jest": "^29.6.2",
|
|
95
95
|
"jest-environment-node-single-context": "^29.1.0",
|
|
96
96
|
"lint-staged": "^15.2.0",
|
|
@@ -105,7 +105,7 @@
|
|
|
105
105
|
"semver": "^7.5.4",
|
|
106
106
|
"standard-version": "^9.3.1",
|
|
107
107
|
"style-loader": "^3.3.4",
|
|
108
|
-
"webpack": "^5.
|
|
108
|
+
"webpack": "^5.93.0",
|
|
109
109
|
"webpack-cli": "^5.1.4",
|
|
110
110
|
"webpack-dev-server": "^5.0.4"
|
|
111
111
|
},
|