less-loader 7.0.1 → 7.2.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 +27 -0
- package/README.md +48 -93
- package/dist/LessError.js +4 -4
- package/dist/cjs.js +1 -1
- package/dist/index.js +9 -9
- package/dist/utils.js +14 -18
- package/package.json +22 -23
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,33 @@
|
|
|
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
|
+
### [7.2.1](https://github.com/webpack-contrib/less-loader/compare/v7.2.0...v7.2.1) (2020-12-28)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* errors from less ([#401](https://github.com/webpack-contrib/less-loader/issues/401)) ([ce31aca](https://github.com/webpack-contrib/less-loader/commit/ce31aca7aada70a8cc267449954ab38b642cd4ba))
|
|
11
|
+
|
|
12
|
+
## [7.2.0](https://github.com/webpack-contrib/less-loader/compare/v7.1.0...v7.2.0) (2020-12-23)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* add less ^4.0 to peerDependencies ([#398](https://github.com/webpack-contrib/less-loader/issues/398)) ([3d1abb7](https://github.com/webpack-contrib/less-loader/commit/3d1abb7be041e44fce59b2109d02eada1451a4e4))
|
|
18
|
+
|
|
19
|
+
## [7.1.0](https://github.com/webpack-contrib/less-loader/compare/v7.0.2...v7.1.0) (2020-11-11)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Features
|
|
23
|
+
|
|
24
|
+
* allow the `additionalData` to be async ([#391](https://github.com/webpack-contrib/less-loader/issues/391)) ([62c6934](https://github.com/webpack-contrib/less-loader/commit/62c6934367eb4dd0d4f3155ed2bb5f3e065aafba))
|
|
25
|
+
|
|
26
|
+
### [7.0.2](https://github.com/webpack-contrib/less-loader/compare/v7.0.1...v7.0.2) (2020-10-09)
|
|
27
|
+
|
|
28
|
+
### Chore
|
|
29
|
+
|
|
30
|
+
* update `schema-utils`
|
|
31
|
+
|
|
5
32
|
### [7.0.1](https://github.com/webpack-contrib/less-loader/compare/v7.0.0...v7.0.1) (2020-09-03)
|
|
6
33
|
|
|
7
34
|
|
package/README.md
CHANGED
|
@@ -34,7 +34,7 @@ module.exports = {
|
|
|
34
34
|
rules: [
|
|
35
35
|
{
|
|
36
36
|
test: /\.less$/,
|
|
37
|
-
loader:
|
|
37
|
+
loader: "less-loader", // compiles Less to CSS
|
|
38
38
|
},
|
|
39
39
|
],
|
|
40
40
|
},
|
|
@@ -73,13 +73,13 @@ module.exports = {
|
|
|
73
73
|
test: /\.less$/,
|
|
74
74
|
use: [
|
|
75
75
|
{
|
|
76
|
-
loader:
|
|
76
|
+
loader: "style-loader",
|
|
77
77
|
},
|
|
78
78
|
{
|
|
79
|
-
loader:
|
|
79
|
+
loader: "css-loader",
|
|
80
80
|
},
|
|
81
81
|
{
|
|
82
|
-
loader:
|
|
82
|
+
loader: "less-loader",
|
|
83
83
|
options: {
|
|
84
84
|
lessOptions: {
|
|
85
85
|
strictMath: true,
|
|
@@ -104,24 +104,24 @@ module.exports = {
|
|
|
104
104
|
{
|
|
105
105
|
test: /\.less$/,
|
|
106
106
|
use: [
|
|
107
|
-
|
|
108
|
-
|
|
107
|
+
"style-loader",
|
|
108
|
+
"css-loader",
|
|
109
109
|
{
|
|
110
|
-
loader:
|
|
110
|
+
loader: "less-loader",
|
|
111
111
|
options: {
|
|
112
112
|
lessOptions: (loaderContext) => {
|
|
113
113
|
// More information about available properties https://webpack.js.org/api/loaders/
|
|
114
114
|
const { resourcePath, rootContext } = loaderContext;
|
|
115
115
|
const relativePath = path.relative(rootContext, resourcePath);
|
|
116
116
|
|
|
117
|
-
if (relativePath ===
|
|
117
|
+
if (relativePath === "styles/foo.less") {
|
|
118
118
|
return {
|
|
119
|
-
paths: [
|
|
119
|
+
paths: ["absolute/path/c", "absolute/path/d"],
|
|
120
120
|
};
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
return {
|
|
124
|
-
paths: [
|
|
124
|
+
paths: ["absolute/path/a", "absolute/path/b"],
|
|
125
125
|
};
|
|
126
126
|
},
|
|
127
127
|
},
|
|
@@ -154,10 +154,10 @@ module.exports = {
|
|
|
154
154
|
{
|
|
155
155
|
test: /\.less$/,
|
|
156
156
|
use: [
|
|
157
|
-
|
|
158
|
-
|
|
157
|
+
"style-loader",
|
|
158
|
+
"css-loader",
|
|
159
159
|
{
|
|
160
|
-
loader:
|
|
160
|
+
loader: "less-loader",
|
|
161
161
|
options: {
|
|
162
162
|
additionalData: `@env: ${process.env.NODE_ENV};`,
|
|
163
163
|
},
|
|
@@ -171,6 +171,8 @@ module.exports = {
|
|
|
171
171
|
|
|
172
172
|
#### `Function`
|
|
173
173
|
|
|
174
|
+
##### Sync
|
|
175
|
+
|
|
174
176
|
```js
|
|
175
177
|
module.exports = {
|
|
176
178
|
module: {
|
|
@@ -178,21 +180,21 @@ module.exports = {
|
|
|
178
180
|
{
|
|
179
181
|
test: /\.less$/,
|
|
180
182
|
use: [
|
|
181
|
-
|
|
182
|
-
|
|
183
|
+
"style-loader",
|
|
184
|
+
"css-loader",
|
|
183
185
|
{
|
|
184
|
-
loader:
|
|
186
|
+
loader: "less-loader",
|
|
185
187
|
options: {
|
|
186
188
|
additionalData: (content, loaderContext) => {
|
|
187
189
|
// More information about available properties https://webpack.js.org/api/loaders/
|
|
188
190
|
const { resourcePath, rootContext } = loaderContext;
|
|
189
191
|
const relativePath = path.relative(rootContext, resourcePath);
|
|
190
192
|
|
|
191
|
-
if (relativePath ===
|
|
192
|
-
return
|
|
193
|
+
if (relativePath === "styles/foo.less") {
|
|
194
|
+
return "@value: 100px;" + content;
|
|
193
195
|
}
|
|
194
196
|
|
|
195
|
-
return
|
|
197
|
+
return "@value: 200px;" + content;
|
|
196
198
|
},
|
|
197
199
|
},
|
|
198
200
|
},
|
|
@@ -203,31 +205,7 @@ module.exports = {
|
|
|
203
205
|
};
|
|
204
206
|
```
|
|
205
207
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
```js
|
|
209
|
-
module.exports = {
|
|
210
|
-
module: {
|
|
211
|
-
rules: [
|
|
212
|
-
{
|
|
213
|
-
test: /\.less$/,
|
|
214
|
-
use: [
|
|
215
|
-
'style-loader',
|
|
216
|
-
'css-loader',
|
|
217
|
-
{
|
|
218
|
-
loader: 'less-loader',
|
|
219
|
-
options: {
|
|
220
|
-
appendData: `@env: ${process.env.NODE_ENV};`,
|
|
221
|
-
},
|
|
222
|
-
},
|
|
223
|
-
],
|
|
224
|
-
},
|
|
225
|
-
],
|
|
226
|
-
},
|
|
227
|
-
};
|
|
228
|
-
```
|
|
229
|
-
|
|
230
|
-
#### `Function`
|
|
208
|
+
##### Async
|
|
231
209
|
|
|
232
210
|
```js
|
|
233
211
|
module.exports = {
|
|
@@ -236,21 +214,21 @@ module.exports = {
|
|
|
236
214
|
{
|
|
237
215
|
test: /\.less$/,
|
|
238
216
|
use: [
|
|
239
|
-
|
|
240
|
-
|
|
217
|
+
"style-loader",
|
|
218
|
+
"css-loader",
|
|
241
219
|
{
|
|
242
|
-
loader:
|
|
220
|
+
loader: "less-loader",
|
|
243
221
|
options: {
|
|
244
|
-
|
|
222
|
+
additionalData: async (content, loaderContext) => {
|
|
245
223
|
// More information about available properties https://webpack.js.org/api/loaders/
|
|
246
224
|
const { resourcePath, rootContext } = loaderContext;
|
|
247
225
|
const relativePath = path.relative(rootContext, resourcePath);
|
|
248
226
|
|
|
249
|
-
if (relativePath ===
|
|
250
|
-
return
|
|
227
|
+
if (relativePath === "styles/foo.less") {
|
|
228
|
+
return "@value: 100px;" + content;
|
|
251
229
|
}
|
|
252
230
|
|
|
253
|
-
return
|
|
231
|
+
return "@value: 200px;" + content;
|
|
254
232
|
},
|
|
255
233
|
},
|
|
256
234
|
},
|
|
@@ -277,15 +255,15 @@ module.exports = {
|
|
|
277
255
|
{
|
|
278
256
|
test: /\.less$/i,
|
|
279
257
|
use: [
|
|
280
|
-
|
|
258
|
+
"style-loader",
|
|
281
259
|
{
|
|
282
|
-
loader:
|
|
260
|
+
loader: "css-loader",
|
|
283
261
|
options: {
|
|
284
262
|
sourceMap: true,
|
|
285
263
|
},
|
|
286
264
|
},
|
|
287
265
|
{
|
|
288
|
-
loader:
|
|
266
|
+
loader: "less-loader",
|
|
289
267
|
options: {
|
|
290
268
|
sourceMap: true,
|
|
291
269
|
},
|
|
@@ -315,10 +293,10 @@ module.exports = {
|
|
|
315
293
|
{
|
|
316
294
|
test: /\.less$/i,
|
|
317
295
|
use: [
|
|
318
|
-
|
|
319
|
-
|
|
296
|
+
"style-loader",
|
|
297
|
+
"css-loader",
|
|
320
298
|
{
|
|
321
|
-
loader:
|
|
299
|
+
loader: "less-loader",
|
|
322
300
|
options: {
|
|
323
301
|
webpackImporter: false,
|
|
324
302
|
},
|
|
@@ -346,13 +324,13 @@ module.exports = {
|
|
|
346
324
|
test: /\.less$/,
|
|
347
325
|
use: [
|
|
348
326
|
{
|
|
349
|
-
loader:
|
|
327
|
+
loader: "style-loader", // creates style nodes from JS strings
|
|
350
328
|
},
|
|
351
329
|
{
|
|
352
|
-
loader:
|
|
330
|
+
loader: "css-loader", // translates CSS into CommonJS
|
|
353
331
|
},
|
|
354
332
|
{
|
|
355
|
-
loader:
|
|
333
|
+
loader: "less-loader", // compiles Less to CSS
|
|
356
334
|
},
|
|
357
335
|
],
|
|
358
336
|
},
|
|
@@ -371,21 +349,21 @@ To enable sourcemaps for CSS, you'll need to pass the `sourceMap` property in th
|
|
|
371
349
|
|
|
372
350
|
```javascript
|
|
373
351
|
module.exports = {
|
|
374
|
-
devtool:
|
|
352
|
+
devtool: "source-map", // any "source-map"-like devtool is possible
|
|
375
353
|
module: {
|
|
376
354
|
rules: [
|
|
377
355
|
{
|
|
378
356
|
test: /\.less$/,
|
|
379
357
|
use: [
|
|
380
|
-
|
|
358
|
+
"style-loader",
|
|
381
359
|
{
|
|
382
|
-
loader:
|
|
360
|
+
loader: "css-loader",
|
|
383
361
|
options: {
|
|
384
362
|
sourceMap: true,
|
|
385
363
|
},
|
|
386
364
|
},
|
|
387
365
|
{
|
|
388
|
-
loader:
|
|
366
|
+
loader: "less-loader",
|
|
389
367
|
options: {
|
|
390
368
|
sourceMap: true,
|
|
391
369
|
},
|
|
@@ -412,34 +390,11 @@ Starting with `less-loader` 4, you can now choose between Less' builtin resolver
|
|
|
412
390
|
webpack provides an [advanced mechanism to resolve files](https://webpack.js.org/configuration/resolve/). The `less-loader` applies a Less plugin that passes all queries to the webpack resolver. Thus you can import your Less modules from `node_modules`. Just prepend them with a `~` which tells webpack to look up the [`modules`](https://webpack.js.org/configuration/resolve/#resolve-modules).
|
|
413
391
|
|
|
414
392
|
```css
|
|
415
|
-
@import
|
|
393
|
+
@import "~bootstrap/less/bootstrap";
|
|
416
394
|
```
|
|
417
395
|
|
|
418
396
|
It's important to only prepend it with `~`, because `~/` resolves to the home-directory. webpack needs to distinguish between `bootstrap` and `~bootstrap`, because CSS and Less files have no special syntax for importing relative files. Writing `@import "file"` is the same as `@import "./file";`
|
|
419
397
|
|
|
420
|
-
##### Non-Less imports
|
|
421
|
-
|
|
422
|
-
Using webpack's resolver, you can import any file type. You just need a loader that exports valid Less code. Often, you will also want to set the `issuer` condition to ensure that this rule is only applied on imports originating from Less files:
|
|
423
|
-
|
|
424
|
-
```js
|
|
425
|
-
// webpack.config.js
|
|
426
|
-
module.exports = {
|
|
427
|
-
module: {
|
|
428
|
-
rules: [
|
|
429
|
-
{
|
|
430
|
-
test: /\.js$/,
|
|
431
|
-
issuer: /\.less$/,
|
|
432
|
-
use: [
|
|
433
|
-
{
|
|
434
|
-
loader: 'js-to-less-loader',
|
|
435
|
-
},
|
|
436
|
-
],
|
|
437
|
-
},
|
|
438
|
-
],
|
|
439
|
-
},
|
|
440
|
-
};
|
|
441
|
-
```
|
|
442
|
-
|
|
443
398
|
#### Less resolver
|
|
444
399
|
|
|
445
400
|
If you specify the `paths` option, modules will be searched in the given `paths`. This is Less' default behavior. `paths` should be an array with absolute paths:
|
|
@@ -454,16 +409,16 @@ module.exports = {
|
|
|
454
409
|
test: /\.less$/,
|
|
455
410
|
use: [
|
|
456
411
|
{
|
|
457
|
-
loader:
|
|
412
|
+
loader: "style-loader",
|
|
458
413
|
},
|
|
459
414
|
{
|
|
460
|
-
loader:
|
|
415
|
+
loader: "css-loader",
|
|
461
416
|
},
|
|
462
417
|
{
|
|
463
|
-
loader:
|
|
418
|
+
loader: "less-loader",
|
|
464
419
|
options: {
|
|
465
420
|
lessOptions: {
|
|
466
|
-
paths: [path.resolve(__dirname,
|
|
421
|
+
paths: [path.resolve(__dirname, "node_modules")],
|
|
467
422
|
},
|
|
468
423
|
},
|
|
469
424
|
},
|
|
@@ -503,7 +458,7 @@ module.exports = {
|
|
|
503
458
|
```js
|
|
504
459
|
module.exports = {
|
|
505
460
|
install: function (less, pluginManager, functions) {
|
|
506
|
-
functions.add(
|
|
461
|
+
functions.add("pi", function () {
|
|
507
462
|
// Loader context is available in `less.webpackLoaderContext`
|
|
508
463
|
|
|
509
464
|
return Math.PI;
|
package/dist/LessError.js
CHANGED
|
@@ -12,23 +12,23 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
12
12
|
class LessError extends Error {
|
|
13
13
|
constructor(error) {
|
|
14
14
|
super();
|
|
15
|
-
this.message = [
|
|
15
|
+
this.message = ["\n", ...LessError.getFileExcerptIfPossible(error), error.message.charAt(0).toUpperCase() + error.message.slice(1), error.filename ? ` Error in ${_path.default.normalize(error.filename)} (line ${error.line}, column ${error.column})` : ""].join("\n");
|
|
16
16
|
this.hideStack = true;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
static getFileExcerptIfPossible(lessError) {
|
|
20
|
-
if (typeof lessError.extract ===
|
|
20
|
+
if (typeof lessError.extract === "undefined") {
|
|
21
21
|
return [];
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
const excerpt = lessError.extract.slice(0, 2);
|
|
25
25
|
const column = Math.max(lessError.column - 1, 0);
|
|
26
26
|
|
|
27
|
-
if (typeof excerpt[0] ===
|
|
27
|
+
if (typeof excerpt[0] === "undefined") {
|
|
28
28
|
excerpt.shift();
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
excerpt.push(`${new Array(column).join(
|
|
31
|
+
excerpt.push(`${new Array(column).join(" ")}^`);
|
|
32
32
|
return excerpt;
|
|
33
33
|
}
|
|
34
34
|
|
package/dist/cjs.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -11,7 +11,7 @@ var _less = _interopRequireDefault(require("less"));
|
|
|
11
11
|
|
|
12
12
|
var _loaderUtils = require("loader-utils");
|
|
13
13
|
|
|
14
|
-
var _schemaUtils =
|
|
14
|
+
var _schemaUtils = require("schema-utils");
|
|
15
15
|
|
|
16
16
|
var _options = _interopRequireDefault(require("./options.json"));
|
|
17
17
|
|
|
@@ -23,13 +23,13 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
23
23
|
|
|
24
24
|
async function lessLoader(source) {
|
|
25
25
|
const options = (0, _loaderUtils.getOptions)(this);
|
|
26
|
-
(0, _schemaUtils.
|
|
27
|
-
name:
|
|
28
|
-
baseDataPath:
|
|
26
|
+
(0, _schemaUtils.validate)(_options.default, options, {
|
|
27
|
+
name: "Less Loader",
|
|
28
|
+
baseDataPath: "options"
|
|
29
29
|
});
|
|
30
30
|
const callback = this.async();
|
|
31
31
|
const lessOptions = (0, _utils.getLessOptions)(this, options);
|
|
32
|
-
const useSourceMap = typeof options.sourceMap ===
|
|
32
|
+
const useSourceMap = typeof options.sourceMap === "boolean" ? options.sourceMap : this.sourceMap;
|
|
33
33
|
|
|
34
34
|
if (useSourceMap) {
|
|
35
35
|
lessOptions.sourceMap = {
|
|
@@ -39,8 +39,8 @@ async function lessLoader(source) {
|
|
|
39
39
|
|
|
40
40
|
let data = source;
|
|
41
41
|
|
|
42
|
-
if (typeof options.additionalData !==
|
|
43
|
-
data = typeof options.additionalData ===
|
|
42
|
+
if (typeof options.additionalData !== "undefined") {
|
|
43
|
+
data = typeof options.additionalData === "function" ? `${await options.additionalData(data, this)}` : `${options.additionalData}\n${data}`;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
let result;
|
|
@@ -49,7 +49,7 @@ async function lessLoader(source) {
|
|
|
49
49
|
result = await _less.default.render(data, lessOptions);
|
|
50
50
|
} catch (error) {
|
|
51
51
|
if (error.filename) {
|
|
52
|
-
// `less`
|
|
52
|
+
// `less` returns forward slashes on windows when `webpack` resolver return an absolute windows path in `WebpackFileManager`
|
|
53
53
|
// Ref: https://github.com/webpack-contrib/less-loader/issues/357
|
|
54
54
|
this.addDependency(_path.default.normalize(error.filename));
|
|
55
55
|
}
|
|
@@ -71,7 +71,7 @@ async function lessLoader(source) {
|
|
|
71
71
|
|
|
72
72
|
this.addDependency(_path.default.normalize(item));
|
|
73
73
|
});
|
|
74
|
-
let map = typeof result.map ===
|
|
74
|
+
let map = typeof result.map === "string" ? JSON.parse(result.map) : result.map;
|
|
75
75
|
|
|
76
76
|
if (map && useSourceMap) {
|
|
77
77
|
map = (0, _utils.normalizeSourceMap)(map, this.rootContext);
|
package/dist/utils.js
CHANGED
|
@@ -34,15 +34,15 @@ const IS_NATIVE_WIN32_PATH = /^[a-z]:[/\\]|^\\\\/i;
|
|
|
34
34
|
|
|
35
35
|
function createWebpackLessPlugin(loaderContext) {
|
|
36
36
|
const resolve = loaderContext.getResolve({
|
|
37
|
-
conditionNames: [
|
|
38
|
-
mainFields: [
|
|
39
|
-
mainFiles: [
|
|
40
|
-
extensions: [
|
|
37
|
+
conditionNames: ["less", "style"],
|
|
38
|
+
mainFields: ["less", "style", "main", "..."],
|
|
39
|
+
mainFiles: ["index", "..."],
|
|
40
|
+
extensions: [".less", ".css"]
|
|
41
41
|
});
|
|
42
42
|
|
|
43
43
|
class WebpackFileManager extends _less.default.FileManager {
|
|
44
44
|
supports(filename) {
|
|
45
|
-
if (filename[0] ===
|
|
45
|
+
if (filename[0] === "/" || IS_NATIVE_WIN32_PATH.test(filename)) {
|
|
46
46
|
return true;
|
|
47
47
|
}
|
|
48
48
|
|
|
@@ -64,9 +64,9 @@ function createWebpackLessPlugin(loaderContext) {
|
|
|
64
64
|
|
|
65
65
|
async resolveFilename(filename, currentDirectory) {
|
|
66
66
|
// Less is giving us trailing slashes, but the context should have no trailing slash
|
|
67
|
-
const context = currentDirectory.replace(trailingSlash,
|
|
67
|
+
const context = currentDirectory.replace(trailingSlash, "");
|
|
68
68
|
const request = (0, _loaderUtils.urlToRequest)(filename, // eslint-disable-next-line no-undefined
|
|
69
|
-
filename.charAt(0) ===
|
|
69
|
+
filename.charAt(0) === "/" ? loaderContext.rootContext : undefined);
|
|
70
70
|
return this.resolveRequests(context, [...new Set([request, filename])]);
|
|
71
71
|
}
|
|
72
72
|
|
|
@@ -75,9 +75,7 @@ function createWebpackLessPlugin(loaderContext) {
|
|
|
75
75
|
return Promise.reject();
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
return resolve(context, possibleRequests[0]).then(result => {
|
|
79
|
-
return result;
|
|
80
|
-
}).catch(error => {
|
|
78
|
+
return resolve(context, possibleRequests[0]).then(result => result).catch(error => {
|
|
81
79
|
const [, ...tailPossibleRequests] = possibleRequests;
|
|
82
80
|
|
|
83
81
|
if (tailPossibleRequests.length === 0) {
|
|
@@ -94,13 +92,13 @@ function createWebpackLessPlugin(loaderContext) {
|
|
|
94
92
|
try {
|
|
95
93
|
if (IS_SPECIAL_MODULE_IMPORT.test(filename)) {
|
|
96
94
|
const error = new Error();
|
|
97
|
-
error.type =
|
|
95
|
+
error.type = "Next";
|
|
98
96
|
throw error;
|
|
99
97
|
}
|
|
100
98
|
|
|
101
99
|
result = await super.loadFile(filename, ...args);
|
|
102
100
|
} catch (error) {
|
|
103
|
-
if (error.type !==
|
|
101
|
+
if (error.type !== "File" && error.type !== "Next") {
|
|
104
102
|
return Promise.reject(error);
|
|
105
103
|
}
|
|
106
104
|
|
|
@@ -139,7 +137,7 @@ function createWebpackLessPlugin(loaderContext) {
|
|
|
139
137
|
|
|
140
138
|
|
|
141
139
|
function getLessOptions(loaderContext, loaderOptions) {
|
|
142
|
-
const options = (0, _full.klona)(typeof loaderOptions.lessOptions ===
|
|
140
|
+
const options = (0, _full.klona)(typeof loaderOptions.lessOptions === "function" ? loaderOptions.lessOptions(loaderContext) || {} : loaderOptions.lessOptions || {});
|
|
143
141
|
const lessOptions = {
|
|
144
142
|
plugins: [],
|
|
145
143
|
relativeUrls: true,
|
|
@@ -147,7 +145,7 @@ function getLessOptions(loaderContext, loaderOptions) {
|
|
|
147
145
|
filename: loaderContext.resourcePath,
|
|
148
146
|
...options
|
|
149
147
|
};
|
|
150
|
-
const shouldUseWebpackImporter = typeof loaderOptions.webpackImporter ===
|
|
148
|
+
const shouldUseWebpackImporter = typeof loaderOptions.webpackImporter === "boolean" ? loaderOptions.webpackImporter : true;
|
|
151
149
|
|
|
152
150
|
if (shouldUseWebpackImporter) {
|
|
153
151
|
lessOptions.plugins.unshift(createWebpackLessPlugin(loaderContext));
|
|
@@ -181,11 +179,9 @@ function normalizeSourceMap(map) {
|
|
|
181
179
|
|
|
182
180
|
delete newMap.file; // eslint-disable-next-line no-param-reassign
|
|
183
181
|
|
|
184
|
-
newMap.sourceRoot =
|
|
182
|
+
newMap.sourceRoot = ""; // `less` returns POSIX paths, that's why we need to transform them back to native paths.
|
|
185
183
|
// eslint-disable-next-line no-param-reassign
|
|
186
184
|
|
|
187
|
-
newMap.sources = newMap.sources.map(source =>
|
|
188
|
-
return _path.default.normalize(source);
|
|
189
|
-
});
|
|
185
|
+
newMap.sources = newMap.sources.map(source => _path.default.normalize(source));
|
|
190
186
|
return newMap;
|
|
191
187
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "less-loader",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.2.1",
|
|
4
4
|
"description": "A Less loader for webpack. Compiles Less to CSS.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "webpack-contrib/less-loader",
|
|
@@ -38,41 +38,40 @@
|
|
|
38
38
|
"dist"
|
|
39
39
|
],
|
|
40
40
|
"peerDependencies": {
|
|
41
|
-
"less": "^3.5.0",
|
|
41
|
+
"less": "^3.5.0 || ^4.0.0",
|
|
42
42
|
"webpack": "^4.0.0 || ^5.0.0"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"klona": "^2.0.
|
|
45
|
+
"klona": "^2.0.4",
|
|
46
46
|
"loader-utils": "^2.0.0",
|
|
47
|
-
"schema-utils": "^
|
|
47
|
+
"schema-utils": "^3.0.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@babel/cli": "^7.
|
|
51
|
-
"@babel/core": "^7.
|
|
52
|
-
"@babel/preset-env": "^7.11
|
|
53
|
-
"@commitlint/cli": "^
|
|
54
|
-
"@commitlint/config-conventional": "^
|
|
50
|
+
"@babel/cli": "^7.12.10",
|
|
51
|
+
"@babel/core": "^7.12.10",
|
|
52
|
+
"@babel/preset-env": "^7.12.11",
|
|
53
|
+
"@commitlint/cli": "^11.0.0",
|
|
54
|
+
"@commitlint/config-conventional": "^11.0.0",
|
|
55
55
|
"@webpack-contrib/defaults": "^6.3.0",
|
|
56
56
|
"@webpack-contrib/eslint-config-webpack": "^3.0.0",
|
|
57
|
-
"babel-jest": "^26.
|
|
58
|
-
"cross-env": "^7.0.
|
|
59
|
-
"del": "^
|
|
57
|
+
"babel-jest": "^26.6.3",
|
|
58
|
+
"cross-env": "^7.0.3",
|
|
59
|
+
"del": "^6.0.0",
|
|
60
60
|
"del-cli": "^3.0.1",
|
|
61
|
-
"eslint": "^7.
|
|
62
|
-
"eslint-config-prettier": "^
|
|
63
|
-
"eslint-plugin-import": "^2.22.
|
|
64
|
-
"eslint-plugin-prettier": "^3.
|
|
65
|
-
"husky": "^4.
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"lint-staged": "^10.3.0",
|
|
61
|
+
"eslint": "^7.16.0",
|
|
62
|
+
"eslint-config-prettier": "^7.1.0",
|
|
63
|
+
"eslint-plugin-import": "^2.22.1",
|
|
64
|
+
"eslint-plugin-prettier": "^3.3.0",
|
|
65
|
+
"husky": "^4.3.6",
|
|
66
|
+
"jest": "^26.6.3",
|
|
67
|
+
"less": "^4.0.0",
|
|
68
|
+
"lint-staged": "^10.5.3",
|
|
70
69
|
"memfs": "^3.2.0",
|
|
71
70
|
"npm-run-all": "^4.1.5",
|
|
72
|
-
"prettier": "^2.
|
|
71
|
+
"prettier": "^2.2.1",
|
|
73
72
|
"standard-version": "^9.0.0",
|
|
74
73
|
"strip-ansi": "^6.0.0",
|
|
75
|
-
"webpack": "^
|
|
74
|
+
"webpack": "^5.11.0"
|
|
76
75
|
},
|
|
77
76
|
"keywords": [
|
|
78
77
|
"webpack",
|