sass-loader 11.0.0 → 11.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/CHANGELOG.md +7 -0
- package/dist/utils.js +16 -10
- package/package.json +6 -5
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [11.0.1](https://github.com/webpack-contrib/sass-loader/compare/v11.0.0...v11.0.1) (2021-02-08)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* compatibility with custom importers for `node-sass` ([#927](https://github.com/webpack-contrib/sass-loader/issues/927)) ([af5a072](https://github.com/webpack-contrib/sass-loader/commit/af5a072c5170f96f3d0643dec658248d98f65ff7))
|
|
11
|
+
|
|
5
12
|
## [11.0.0](https://github.com/webpack-contrib/sass-loader/compare/v10.1.1...v11.0.0) (2021-02-05)
|
|
6
13
|
|
|
7
14
|
|
package/dist/utils.js
CHANGED
|
@@ -175,7 +175,9 @@ async function getSassOptions(loaderContext, loaderOptions, content, implementat
|
|
|
175
175
|
options.includePaths = [].concat(process.cwd()).concat( // We use `includePaths` in context for resolver, so it should be always absolute
|
|
176
176
|
(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" ? ";" : ":") : []);
|
|
177
177
|
return options;
|
|
178
|
-
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
const MODULE_REQUEST_REGEX = /^[^?]*~/; // Examples:
|
|
179
181
|
// - ~package
|
|
180
182
|
// - ~package/
|
|
181
183
|
// - ~@org
|
|
@@ -183,9 +185,7 @@ async function getSassOptions(loaderContext, loaderOptions, content, implementat
|
|
|
183
185
|
// - ~@org/package
|
|
184
186
|
// - ~@org/package/
|
|
185
187
|
|
|
186
|
-
|
|
187
|
-
const isModuleImport = /^~([^/]+|[^/]+\/|@[^/]+[/][^/]+|@[^/]+\/?|@[^/]+[/][^/]+\/)$/;
|
|
188
|
-
const MODULE_REQUEST_REGEX = /^[^?]*~/;
|
|
188
|
+
const IS_MODULE_IMPORT = /^~([^/]+|[^/]+\/|@[^/]+[/][^/]+|@[^/]+\/?|@[^/]+[/][^/]+\/)$/;
|
|
189
189
|
/**
|
|
190
190
|
* When `sass`/`node-sass` tries to resolve an import, it uses a special algorithm.
|
|
191
191
|
* Since the `sass-loader` uses webpack to resolve the modules, we need to simulate that algorithm.
|
|
@@ -210,7 +210,7 @@ url, forWebpackResolver = false) {
|
|
|
210
210
|
request = request.replace(MODULE_REQUEST_REGEX, "");
|
|
211
211
|
}
|
|
212
212
|
|
|
213
|
-
if (
|
|
213
|
+
if (IS_MODULE_IMPORT.test(url)) {
|
|
214
214
|
request = request[request.length - 1] === "/" ? request : `${request}/`;
|
|
215
215
|
return [...new Set([request, url])];
|
|
216
216
|
}
|
|
@@ -268,12 +268,11 @@ const IS_NATIVE_WIN32_PATH = /^[a-z]:[/\\]|^\\\\/i;
|
|
|
268
268
|
* @param {Object} implementation - The imported Sass implementation, both
|
|
269
269
|
* `sass` (Dart Sass) and `node-sass` are supported.
|
|
270
270
|
* @param {string[]} [includePaths] - The list of include paths passed to Sass.
|
|
271
|
-
* @param {boolean} [rootContext] - The configured Webpack root context.
|
|
272
271
|
*
|
|
273
272
|
* @throws If a compatible Sass implementation cannot be found.
|
|
274
273
|
*/
|
|
275
274
|
|
|
276
|
-
function getWebpackResolver(resolverFactory, implementation, includePaths = []
|
|
275
|
+
function getWebpackResolver(resolverFactory, implementation, includePaths = []) {
|
|
277
276
|
async function startResolving(resolutionMap) {
|
|
278
277
|
if (resolutionMap.length === 0) {
|
|
279
278
|
return Promise.reject();
|
|
@@ -332,6 +331,13 @@ function getWebpackResolver(resolverFactory, implementation, includePaths = [],
|
|
|
332
331
|
preferRelative: true
|
|
333
332
|
}));
|
|
334
333
|
return (context, request) => {
|
|
334
|
+
// See https://github.com/webpack/webpack/issues/12340
|
|
335
|
+
// Because `node-sass` calls our importer before `1. Filesystem imports relative to the base file.`
|
|
336
|
+
// custom importer may not return `{ file: '/path/to/name.ext' }` and therefore our `context` will be relative
|
|
337
|
+
if (!isDartSass && !_path.default.isAbsolute(context)) {
|
|
338
|
+
return Promise.reject();
|
|
339
|
+
}
|
|
340
|
+
|
|
335
341
|
const originalRequest = request;
|
|
336
342
|
const isFileScheme = originalRequest.slice(0, 5).toLowerCase() === "file:";
|
|
337
343
|
|
|
@@ -362,7 +368,7 @@ function getWebpackResolver(resolverFactory, implementation, includePaths = [],
|
|
|
362
368
|
// 4. Filesystem imports relative to an `includePaths` path.
|
|
363
369
|
// 5. Filesystem imports relative to a `SASS_PATH` path.
|
|
364
370
|
//
|
|
365
|
-
//
|
|
371
|
+
// `sass` run custom importers before `3`, `4` and `5` points, we need to emulate this behavior to avoid wrong resolution.
|
|
366
372
|
const sassPossibleRequests = getPossibleRequests(request); // `node-sass` calls our importer before `1. Filesystem imports relative to the base file.`, so we need emulate this too
|
|
367
373
|
|
|
368
374
|
if (!isDartSass) {
|
|
@@ -383,7 +389,7 @@ function getWebpackResolver(resolverFactory, implementation, includePaths = [],
|
|
|
383
389
|
}));
|
|
384
390
|
}
|
|
385
391
|
|
|
386
|
-
const webpackPossibleRequests = getPossibleRequests(request, true
|
|
392
|
+
const webpackPossibleRequests = getPossibleRequests(request, true);
|
|
387
393
|
resolutionMap = resolutionMap.concat({
|
|
388
394
|
resolve: webpackResolve,
|
|
389
395
|
context: _path.default.dirname(context),
|
|
@@ -396,7 +402,7 @@ function getWebpackResolver(resolverFactory, implementation, includePaths = [],
|
|
|
396
402
|
const matchCss = /\.css$/i;
|
|
397
403
|
|
|
398
404
|
function getWebpackImporter(loaderContext, implementation, includePaths) {
|
|
399
|
-
const resolve = getWebpackResolver(loaderContext.getResolve, implementation, includePaths
|
|
405
|
+
const resolve = getWebpackResolver(loaderContext.getResolve, implementation, includePaths);
|
|
400
406
|
return (originalUrl, prev, done) => {
|
|
401
407
|
resolve(prev, originalUrl).then(result => {
|
|
402
408
|
// Add the result as dependency.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sass-loader",
|
|
3
|
-
"version": "11.0.
|
|
3
|
+
"version": "11.0.1",
|
|
4
4
|
"description": "Sass loader for webpack",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "webpack-contrib/sass-loader",
|
|
@@ -39,10 +39,10 @@
|
|
|
39
39
|
"dist"
|
|
40
40
|
],
|
|
41
41
|
"peerDependencies": {
|
|
42
|
-
"
|
|
42
|
+
"fibers": ">= 3.1.0",
|
|
43
43
|
"node-sass": "^4.0.0 || ^5.0.0",
|
|
44
44
|
"sass": "^1.3.0",
|
|
45
|
-
"
|
|
45
|
+
"webpack": "^5.0.0"
|
|
46
46
|
},
|
|
47
47
|
"peerDependenciesMeta": {
|
|
48
48
|
"node-sass": {
|
|
@@ -83,17 +83,18 @@
|
|
|
83
83
|
"foundation-sites": "^6.6.3",
|
|
84
84
|
"husky": "^4.3.6",
|
|
85
85
|
"jest": "^26.6.3",
|
|
86
|
-
"lint-staged": "^10.5.
|
|
86
|
+
"lint-staged": "^10.5.4",
|
|
87
87
|
"material-components-web": "^8.0.0",
|
|
88
88
|
"memfs": "^3.2.0",
|
|
89
89
|
"node-sass": "^5.0.0",
|
|
90
|
+
"node-sass-glob-importer": "^5.3.2",
|
|
90
91
|
"npm-run-all": "^4.1.5",
|
|
91
92
|
"prettier": "^2.2.1",
|
|
92
93
|
"sass": "^1.32.0",
|
|
93
94
|
"semver": "^7.3.4",
|
|
94
95
|
"standard-version": "^9.1.0",
|
|
95
96
|
"style-loader": "^2.0.0",
|
|
96
|
-
"webpack": "^5.
|
|
97
|
+
"webpack": "^5.21.2"
|
|
97
98
|
},
|
|
98
99
|
"keywords": [
|
|
99
100
|
"sass",
|