less-loader 6.1.0 → 6.2.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/CHANGELOG.md +30 -0
- package/dist/LessError.js +5 -1
- package/dist/index.js +14 -2
- package/dist/utils.js +29 -16
- package/package.json +16 -16
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,36 @@
|
|
|
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
|
+
## [6.2.0](https://github.com/webpack-contrib/less-loader/compare/v6.1.3...v6.2.0) (2020-07-03)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* support condition names from `package.json` ([#369](https://github.com/webpack-contrib/less-loader/issues/369)) ([671395d](https://github.com/webpack-contrib/less-loader/commit/671395d6a82425ba4408d1329d8cbfa07dfd9153))
|
|
11
|
+
|
|
12
|
+
### [6.1.3](https://github.com/webpack-contrib/less-loader/compare/v6.1.2...v6.1.3) (2020-06-29)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* revert restrictions ([e758837](https://github.com/webpack-contrib/less-loader/commit/e75883706fc3d3bb2b6283a727a405216473362e))
|
|
18
|
+
|
|
19
|
+
### [6.1.2](https://github.com/webpack-contrib/less-loader/compare/v6.1.1...v6.1.2) (2020-06-22)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Bug Fixes
|
|
23
|
+
|
|
24
|
+
* ignore watch for remove URLs ([3946937](https://github.com/webpack-contrib/less-loader/commit/39469376e28cd0e38162f7bdf8935d343830a40e))
|
|
25
|
+
* resolution logic ([2c3a23a](https://github.com/webpack-contrib/less-loader/commit/2c3a23a440cbdad1edb8b232864cb0233a266782))
|
|
26
|
+
* resolve absolute and root relative imports ([3d01b82](https://github.com/webpack-contrib/less-loader/commit/3d01b82fae335d5d69d6290911e788debc732182))
|
|
27
|
+
|
|
28
|
+
### [6.1.1](https://github.com/webpack-contrib/less-loader/compare/v6.1.0...v6.1.1) (2020-06-11)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
### Bug Fixes
|
|
32
|
+
|
|
33
|
+
* do not rebuilt unmodified files on windows in watch mode ([6537a3d](https://github.com/webpack-contrib/less-loader/commit/6537a3d66559464af9b9a25f4bdda8691e8d9407))
|
|
34
|
+
|
|
5
35
|
## [6.1.0](https://github.com/webpack-contrib/less-loader/compare/v6.0.0...v6.1.0) (2020-05-07)
|
|
6
36
|
|
|
7
37
|
|
package/dist/LessError.js
CHANGED
|
@@ -5,10 +5,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
+
var _path = _interopRequireDefault(require("path"));
|
|
9
|
+
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
|
|
8
12
|
class LessError extends Error {
|
|
9
13
|
constructor(error) {
|
|
10
14
|
super();
|
|
11
|
-
this.message = ['\n', ...LessError.getFileExcerptIfPossible(error), error.message.charAt(0).toUpperCase() + error.message.slice(1), ` Error in ${error.filename} (line ${error.line}, column ${error.column})`].join('\n');
|
|
15
|
+
this.message = ['\n', ...LessError.getFileExcerptIfPossible(error), error.message.charAt(0).toUpperCase() + error.message.slice(1), ` Error in ${_path.default.normalize(error.filename)} (line ${error.line}, column ${error.column})`].join('\n');
|
|
12
16
|
this.hideStack = true;
|
|
13
17
|
}
|
|
14
18
|
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
+
var _path = _interopRequireDefault(require("path"));
|
|
9
|
+
|
|
8
10
|
var _loaderUtils = require("loader-utils");
|
|
9
11
|
|
|
10
12
|
var _schemaUtils = _interopRequireDefault(require("schema-utils"));
|
|
@@ -40,11 +42,21 @@ function lessLoader(source) {
|
|
|
40
42
|
map,
|
|
41
43
|
imports
|
|
42
44
|
}) => {
|
|
43
|
-
imports.forEach(
|
|
45
|
+
imports.forEach(item => {
|
|
46
|
+
if ((0, _utils.isUnsupportedUrl)(item)) {
|
|
47
|
+
return;
|
|
48
|
+
} // `less` return forward slashes on windows when `webpack` resolver return an absolute windows path in `WebpackFileManager`
|
|
49
|
+
// Ref: https://github.com/webpack-contrib/less-loader/issues/357
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
this.addDependency(_path.default.normalize(item));
|
|
53
|
+
});
|
|
44
54
|
callback(null, css, typeof map === 'string' ? JSON.parse(map) : map);
|
|
45
55
|
}).catch(lessError => {
|
|
46
56
|
if (lessError.filename) {
|
|
47
|
-
|
|
57
|
+
// `less` return forward slashes on windows when `webpack` resolver return an absolute windows path in `WebpackFileManager`
|
|
58
|
+
// Ref: https://github.com/webpack-contrib/less-loader/issues/357
|
|
59
|
+
this.addDependency(_path.default.normalize(lessError.filename));
|
|
48
60
|
}
|
|
49
61
|
|
|
50
62
|
callback(new _LessError.default(lessError));
|
package/dist/utils.js
CHANGED
|
@@ -5,6 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.getLessImplementation = getLessImplementation;
|
|
7
7
|
exports.getLessOptions = getLessOptions;
|
|
8
|
+
exports.isUnsupportedUrl = isUnsupportedUrl;
|
|
9
|
+
|
|
10
|
+
var _path = _interopRequireDefault(require("path"));
|
|
8
11
|
|
|
9
12
|
var _less = _interopRequireDefault(require("less"));
|
|
10
13
|
|
|
@@ -19,7 +22,9 @@ const trailingSlash = /[/\\]$/; // This somewhat changed in Less 3.x. Now the fi
|
|
|
19
22
|
// automatically added extension whereas the extension is passed in as `options.ext`.
|
|
20
23
|
// So, if the file name matches this regexp, we simply ignore the proposed extension.
|
|
21
24
|
|
|
22
|
-
const
|
|
25
|
+
const isModuleImport = /^~([^/]+|[^/]+\/|@[^/]+[/][^/]+|@[^/]+\/?|@[^/]+[/][^/]+\/)$/; // `[drive_letter]:\` + `\\[server]\[sharename]\`
|
|
26
|
+
|
|
27
|
+
const isNativeWin32Path = /^[a-zA-Z]:[/\\]|^\\\\/i;
|
|
23
28
|
/**
|
|
24
29
|
* Creates a Less plugin that uses webpack's resolving engine that is provided by the loaderContext.
|
|
25
30
|
*
|
|
@@ -29,6 +34,7 @@ const isModuleName = /^~([^/]+|[^/]+\/|@[^/]+[/][^/]+|@[^/]+\/?|@[^/]+[/][^/]+\/
|
|
|
29
34
|
|
|
30
35
|
function createWebpackLessPlugin(loaderContext) {
|
|
31
36
|
const resolve = loaderContext.getResolve({
|
|
37
|
+
conditionNames: ['less', 'style'],
|
|
32
38
|
mainFields: ['less', 'style', 'main', '...'],
|
|
33
39
|
mainFiles: ['index', '...'],
|
|
34
40
|
extensions: ['.less', '.css']
|
|
@@ -36,6 +42,10 @@ function createWebpackLessPlugin(loaderContext) {
|
|
|
36
42
|
|
|
37
43
|
class WebpackFileManager extends _less.default.FileManager {
|
|
38
44
|
supports(filename) {
|
|
45
|
+
if (filename[0] === '/' || isNativeWin32Path.test(filename)) {
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
|
|
39
49
|
if (this.isPathAbsolute(filename)) {
|
|
40
50
|
return false;
|
|
41
51
|
}
|
|
@@ -52,20 +62,12 @@ function createWebpackLessPlugin(loaderContext) {
|
|
|
52
62
|
return false;
|
|
53
63
|
}
|
|
54
64
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
return this.tryAppendExtension(filename, options.ext);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return filename;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
async resolveFilename(filename, currentDirectory, options) {
|
|
64
|
-
const url = this.getUrl(filename, options);
|
|
65
|
-
const moduleRequest = (0, _loaderUtils.urlToRequest)(url, url.charAt(0) === '/' ? '' : null); // Less is giving us trailing slashes, but the context should have no trailing slash
|
|
66
|
-
|
|
65
|
+
async resolveFilename(filename, currentDirectory) {
|
|
66
|
+
// Less is giving us trailing slashes, but the context should have no trailing slash
|
|
67
67
|
const context = currentDirectory.replace(trailingSlash, '');
|
|
68
|
-
|
|
68
|
+
const request = (0, _loaderUtils.urlToRequest)(filename, // eslint-disable-next-line no-undefined
|
|
69
|
+
filename.charAt(0) === '/' ? loaderContext.rootContext : undefined);
|
|
70
|
+
return this.resolveRequests(context, [...new Set([request, filename])]);
|
|
69
71
|
}
|
|
70
72
|
|
|
71
73
|
resolveRequests(context, possibleRequests) {
|
|
@@ -90,7 +92,7 @@ function createWebpackLessPlugin(loaderContext) {
|
|
|
90
92
|
let result;
|
|
91
93
|
|
|
92
94
|
try {
|
|
93
|
-
if (
|
|
95
|
+
if (isModuleImport.test(filename)) {
|
|
94
96
|
const error = new Error();
|
|
95
97
|
error.type = 'Next';
|
|
96
98
|
throw error;
|
|
@@ -113,7 +115,7 @@ function createWebpackLessPlugin(loaderContext) {
|
|
|
113
115
|
return super.loadFile(result, ...args);
|
|
114
116
|
}
|
|
115
117
|
|
|
116
|
-
loaderContext.addDependency(result.filename);
|
|
118
|
+
loaderContext.addDependency(_path.default.normalize(result.filename));
|
|
117
119
|
return result;
|
|
118
120
|
}
|
|
119
121
|
|
|
@@ -163,4 +165,15 @@ function getLessImplementation(implementation) {
|
|
|
163
165
|
}
|
|
164
166
|
|
|
165
167
|
return _less.default;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function isUnsupportedUrl(url) {
|
|
171
|
+
// Is Windows paths `c:\`
|
|
172
|
+
if (/^[a-zA-Z]:\\/.test(url)) {
|
|
173
|
+
return false;
|
|
174
|
+
} // Scheme: https://tools.ietf.org/html/rfc3986#section-3.1
|
|
175
|
+
// Absolute URL: https://tools.ietf.org/html/rfc3986#section-4.3
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
return /^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(url);
|
|
166
179
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "less-loader",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.2.0",
|
|
4
4
|
"description": "A Less loader for webpack. Compiles Less to CSS.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "webpack-contrib/less-loader",
|
|
@@ -42,31 +42,31 @@
|
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"clone": "^2.1.2",
|
|
45
|
-
"less": "^3.11.
|
|
45
|
+
"less": "^3.11.3",
|
|
46
46
|
"loader-utils": "^2.0.0",
|
|
47
|
-
"schema-utils": "^2.
|
|
47
|
+
"schema-utils": "^2.7.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@babel/cli": "^7.
|
|
51
|
-
"@babel/core": "^7.
|
|
52
|
-
"@babel/preset-env": "^7.
|
|
53
|
-
"@commitlint/cli": "^
|
|
54
|
-
"@commitlint/config-conventional": "^
|
|
50
|
+
"@babel/cli": "^7.10.4",
|
|
51
|
+
"@babel/core": "^7.10.4",
|
|
52
|
+
"@babel/preset-env": "^7.10.4",
|
|
53
|
+
"@commitlint/cli": "^9.0.1",
|
|
54
|
+
"@commitlint/config-conventional": "^9.0.1",
|
|
55
55
|
"@webpack-contrib/defaults": "^6.3.0",
|
|
56
56
|
"@webpack-contrib/eslint-config-webpack": "^3.0.0",
|
|
57
|
-
"babel-jest": "^26.0
|
|
57
|
+
"babel-jest": "^26.1.0",
|
|
58
58
|
"cross-env": "^7.0.2",
|
|
59
59
|
"del": "^5.1.0",
|
|
60
|
-
"del-cli": "^3.0.
|
|
61
|
-
"eslint": "^
|
|
60
|
+
"del-cli": "^3.0.1",
|
|
61
|
+
"eslint": "^7.3.1",
|
|
62
62
|
"eslint-config-prettier": "^6.11.0",
|
|
63
|
-
"eslint-plugin-import": "^2.
|
|
64
|
-
"eslint-plugin-prettier": "^3.1.
|
|
63
|
+
"eslint-plugin-import": "^2.22.0",
|
|
64
|
+
"eslint-plugin-prettier": "^3.1.4",
|
|
65
65
|
"husky": "^4.2.5",
|
|
66
66
|
"inspect-loader": "^1.0.0",
|
|
67
|
-
"jest": "^26.0
|
|
68
|
-
"lint-staged": "^10.2.
|
|
69
|
-
"memfs": "^3.
|
|
67
|
+
"jest": "^26.1.0",
|
|
68
|
+
"lint-staged": "^10.2.11",
|
|
69
|
+
"memfs": "^3.2.0",
|
|
70
70
|
"npm-run-all": "^4.1.5",
|
|
71
71
|
"prettier": "^2.0.5",
|
|
72
72
|
"standard-version": "^8.0.0",
|