sass-loader 15.0.0 → 16.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 +2 -2
- package/dist/index.js +5 -3
- package/dist/utils.js +10 -10
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -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`).
|
|
@@ -559,13 +560,12 @@ const sassModernCompilers = new WeakMap();
|
|
|
559
560
|
*
|
|
560
561
|
* @param {Object} loaderContext
|
|
561
562
|
* @param {Object} implementation
|
|
562
|
-
* @param {
|
|
563
|
+
* @param {"legacy" | "modern" | "modern-compiler"} apiType
|
|
563
564
|
* @returns {Function}
|
|
564
565
|
*/
|
|
565
|
-
function getCompileFn(loaderContext, implementation,
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
if (options.api === "modern") {
|
|
566
|
+
function getCompileFn(loaderContext, implementation, apiType) {
|
|
567
|
+
if (typeof implementation.compileStringAsync !== "undefined") {
|
|
568
|
+
if (apiType === "modern") {
|
|
569
569
|
return sassOptions => {
|
|
570
570
|
const {
|
|
571
571
|
data,
|
|
@@ -574,7 +574,7 @@ function getCompileFn(loaderContext, implementation, options) {
|
|
|
574
574
|
return implementation.compileStringAsync(data, rest);
|
|
575
575
|
};
|
|
576
576
|
}
|
|
577
|
-
if (
|
|
577
|
+
if (apiType === "modern-compiler") {
|
|
578
578
|
return async sassOptions => {
|
|
579
579
|
// eslint-disable-next-line no-underscore-dangle
|
|
580
580
|
const webpackCompiler = loaderContext._compiler;
|
|
@@ -615,7 +615,7 @@ function getCompileFn(loaderContext, implementation, options) {
|
|
|
615
615
|
});
|
|
616
616
|
});
|
|
617
617
|
}
|
|
618
|
-
if (
|
|
618
|
+
if (apiType === "modern" || apiType === "modern-compiler") {
|
|
619
619
|
throw new Error("Modern API is not supported for 'node-sass'");
|
|
620
620
|
}
|
|
621
621
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sass-loader",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "16.0.0",
|
|
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",
|
|
@@ -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
|
},
|