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 +6 -6
- package/dist/index.js +1 -2
- package/dist/utils.js +56 -44
- package/package.json +21 -23
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: `
|
|
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
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 =
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
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 =>
|
|
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
|
-
|
|
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
|
|
134
|
-
builtMessage
|
|
132
|
+
if (loggerOptions.span) {
|
|
133
|
+
builtMessage += formatSpan(loggerOptions.span);
|
|
135
134
|
}
|
|
136
135
|
builtMessage += message;
|
|
137
|
-
if (loggerOptions.
|
|
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
|
-
|
|
158
|
+
sassOptions.url = _url.default.pathToFileURL(resourcePath);
|
|
156
159
|
|
|
157
160
|
// opt.outputStyle
|
|
158
|
-
if (!
|
|
159
|
-
|
|
161
|
+
if (!sassOptions.style && isProductionLikeMode(loaderContext)) {
|
|
162
|
+
sassOptions.style = "compressed";
|
|
160
163
|
}
|
|
161
164
|
if (useSourceMap) {
|
|
162
|
-
|
|
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
|
|
169
|
+
if (typeof sassOptions.syntax === "undefined") {
|
|
167
170
|
const ext = _path.default.extname(resourcePath);
|
|
168
171
|
if (ext && ext.toLowerCase() === ".scss") {
|
|
169
|
-
|
|
172
|
+
sassOptions.syntax = "scss";
|
|
170
173
|
} else if (ext && ext.toLowerCase() === ".sass") {
|
|
171
|
-
|
|
174
|
+
sassOptions.syntax = "indented";
|
|
172
175
|
} else if (ext && ext.toLowerCase() === ".css") {
|
|
173
|
-
|
|
176
|
+
sassOptions.syntax = "css";
|
|
174
177
|
}
|
|
175
178
|
}
|
|
176
|
-
|
|
179
|
+
sassOptions.importers = sassOptions.importers ? Array.isArray(sassOptions.importers) ? sassOptions.importers.slice() : [sassOptions.importers] : [];
|
|
177
180
|
} else {
|
|
178
|
-
|
|
181
|
+
sassOptions.file = resourcePath;
|
|
182
|
+
const isDartSass = implementation.info.includes("dart-sass");
|
|
179
183
|
if (isDartSass && isSupportedFibers()) {
|
|
180
|
-
const shouldTryToResolveFibers = !
|
|
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
|
-
|
|
194
|
+
sassOptions.fiber = require(fibers);
|
|
191
195
|
}
|
|
192
|
-
} else if (
|
|
196
|
+
} else if (sassOptions.fiber === false) {
|
|
193
197
|
// Don't pass the `fiber` option for `sass` (`Dart Sass`)
|
|
194
|
-
delete
|
|
198
|
+
delete sassOptions.fiber;
|
|
195
199
|
}
|
|
196
200
|
} else {
|
|
197
201
|
// Don't pass the `fiber` option for `node-sass`
|
|
198
|
-
delete
|
|
202
|
+
delete sassOptions.fiber;
|
|
199
203
|
}
|
|
200
204
|
|
|
201
205
|
// opt.outputStyle
|
|
202
|
-
if (!
|
|
203
|
-
|
|
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
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
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
|
|
222
|
-
|
|
225
|
+
if (ext && ext.toLowerCase() === ".sass" && typeof sassOptions.indentedSyntax === "undefined") {
|
|
226
|
+
sassOptions.indentedSyntax = true;
|
|
223
227
|
} else {
|
|
224
|
-
|
|
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
|
-
|
|
229
|
-
|
|
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
|
-
(
|
|
232
|
-
if (typeof
|
|
233
|
-
|
|
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
|
|
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
|
-
|
|
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.
|
|
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.
|
|
71
|
-
"@babel/core": "^7.
|
|
72
|
-
"@babel/preset-env": "^7.
|
|
73
|
-
"@commitlint/cli": "^17.6.
|
|
74
|
-
"@commitlint/config-conventional": "^17.6.
|
|
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.
|
|
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.
|
|
82
|
-
"css-loader": "^6.
|
|
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.
|
|
86
|
-
"eslint": "^8.
|
|
87
|
-
"eslint-config-prettier": "^8.
|
|
88
|
-
"eslint-plugin-import": "^2.
|
|
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.
|
|
94
|
-
"jest-environment-node-single-context": "^29.
|
|
95
|
-
"lint-staged": "^13.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.
|
|
103
|
-
"sass-embedded": "^1.
|
|
104
|
-
"semver": "^7.5.
|
|
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.
|
|
107
|
-
"webpack": "^5.
|
|
104
|
+
"style-loader": "^3.3.3",
|
|
105
|
+
"webpack": "^5.88.2"
|
|
108
106
|
},
|
|
109
107
|
"keywords": [
|
|
110
108
|
"sass",
|