less-loader 7.2.1 → 8.1.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 +39 -0
- package/README.md +97 -20
- package/dist/index.js +7 -11
- package/dist/options.json +5 -0
- package/dist/utils.js +53 -12
- package/package.json +17 -22
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,45 @@
|
|
|
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
|
+
### [8.1.1](https://github.com/webpack-contrib/less-loader/compare/v8.1.0...v8.1.1) (2021-04-15)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* deprecation warning ([#415](https://github.com/webpack-contrib/less-loader/issues/415)) ([87a4f25](https://github.com/webpack-contrib/less-loader/commit/87a4f25e2c8343ae2c75486749e57c2d10b1490d))
|
|
11
|
+
|
|
12
|
+
## [8.1.0](https://github.com/webpack-contrib/less-loader/compare/v8.0.0...v8.1.0) (2021-04-09)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* added the `pluginManager.webpackLoaderContext` property for `less` plugin developers, deprecated the `less.webpackLoaderContext` property, it fixed memory leak, please read [this](https://github.com/webpack-contrib/less-loader#plugins) ([#412](https://github.com/webpack-contrib/less-loader/issues/412)) ([e576240](https://github.com/webpack-contrib/less-loader/commit/e5762404093ec6246079c6b975c9f93c0a521bd9))
|
|
18
|
+
|
|
19
|
+
## [8.0.0](https://github.com/webpack-contrib/less-loader/compare/v7.3.0...v8.0.0) (2021-02-01)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Notes
|
|
23
|
+
|
|
24
|
+
* using `~` is deprecated and can be removed from your code (**we recommend it**), but we still support it for historical reasons.
|
|
25
|
+
|
|
26
|
+
Why you can removed it?
|
|
27
|
+
The loader will first try to resolve `@import` as relative, if it cannot be resolved, the loader will try to resolve `@import` inside [`node_modules`](https://webpack.js.org/configuration/resolve/#resolve-modules).
|
|
28
|
+
|
|
29
|
+
### ⚠ BREAKING CHANGES
|
|
30
|
+
|
|
31
|
+
* minimum supported `webpack` version is `5`
|
|
32
|
+
|
|
33
|
+
### Features
|
|
34
|
+
|
|
35
|
+
* supported the [`resolve.byDependency`](https://webpack.js.org/configuration/resolve/#resolvebydependency) option, you can setup `{ resolve: { byDependency: { less: { mainFiles: ['custom', '...'] } } } }`
|
|
36
|
+
|
|
37
|
+
## [7.3.0](https://github.com/webpack-contrib/less-loader/compare/v7.2.1...v7.3.0) (2021-01-21)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
### Features
|
|
41
|
+
|
|
42
|
+
* added the `implementation` option ([84d957c](https://github.com/webpack-contrib/less-loader/commit/84d957cfe4fbd6c97619c647d0dd0917b99408ae))
|
|
43
|
+
|
|
5
44
|
### [7.2.1](https://github.com/webpack-contrib/less-loader/compare/v7.2.0...v7.2.1) (2020-12-28)
|
|
6
45
|
|
|
7
46
|
|
package/README.md
CHANGED
|
@@ -33,8 +33,13 @@ module.exports = {
|
|
|
33
33
|
module: {
|
|
34
34
|
rules: [
|
|
35
35
|
{
|
|
36
|
-
test: /\.less
|
|
37
|
-
loader:
|
|
36
|
+
test: /\.less$/i,
|
|
37
|
+
loader: [
|
|
38
|
+
// compiles Less to CSS
|
|
39
|
+
"style-loader",
|
|
40
|
+
"css-loader",
|
|
41
|
+
"less-loader",
|
|
42
|
+
],
|
|
38
43
|
},
|
|
39
44
|
],
|
|
40
45
|
},
|
|
@@ -51,6 +56,7 @@ And run `webpack` via your preferred method.
|
|
|
51
56
|
| **[`additionalData`](#additionalData)** | `{String\|Function}` | `undefined` | Prepends/Appends `Less` code to the actual entry file. |
|
|
52
57
|
| **[`sourceMap`](#sourcemap)** | `{Boolean}` | `compiler.devtool` | Enables/Disables generation of source maps. |
|
|
53
58
|
| **[`webpackImporter`](#webpackimporter)** | `{Boolean}` | `true` | Enables/Disables the default Webpack importer. |
|
|
59
|
+
| **[`implementation`](#implementation)** | `{Object}` | `less` | Setup Less implementation to use. |
|
|
54
60
|
|
|
55
61
|
### `lessOptions`
|
|
56
62
|
|
|
@@ -70,7 +76,7 @@ module.exports = {
|
|
|
70
76
|
module: {
|
|
71
77
|
rules: [
|
|
72
78
|
{
|
|
73
|
-
test: /\.less
|
|
79
|
+
test: /\.less$/i,
|
|
74
80
|
use: [
|
|
75
81
|
{
|
|
76
82
|
loader: "style-loader",
|
|
@@ -102,7 +108,7 @@ module.exports = {
|
|
|
102
108
|
module: {
|
|
103
109
|
rules: [
|
|
104
110
|
{
|
|
105
|
-
test: /\.less
|
|
111
|
+
test: /\.less$/i,
|
|
106
112
|
use: [
|
|
107
113
|
"style-loader",
|
|
108
114
|
"css-loader",
|
|
@@ -152,7 +158,7 @@ module.exports = {
|
|
|
152
158
|
module: {
|
|
153
159
|
rules: [
|
|
154
160
|
{
|
|
155
|
-
test: /\.less
|
|
161
|
+
test: /\.less$/i,
|
|
156
162
|
use: [
|
|
157
163
|
"style-loader",
|
|
158
164
|
"css-loader",
|
|
@@ -178,7 +184,7 @@ module.exports = {
|
|
|
178
184
|
module: {
|
|
179
185
|
rules: [
|
|
180
186
|
{
|
|
181
|
-
test: /\.less
|
|
187
|
+
test: /\.less$/i,
|
|
182
188
|
use: [
|
|
183
189
|
"style-loader",
|
|
184
190
|
"css-loader",
|
|
@@ -212,7 +218,7 @@ module.exports = {
|
|
|
212
218
|
module: {
|
|
213
219
|
rules: [
|
|
214
220
|
{
|
|
215
|
-
test: /\.less
|
|
221
|
+
test: /\.less$/i,
|
|
216
222
|
use: [
|
|
217
223
|
"style-loader",
|
|
218
224
|
"css-loader",
|
|
@@ -280,7 +286,7 @@ module.exports = {
|
|
|
280
286
|
Type: `Boolean`
|
|
281
287
|
Default: `true`
|
|
282
288
|
|
|
283
|
-
Enables/Disables the default
|
|
289
|
+
Enables/Disables the default `webpack` importer.
|
|
284
290
|
|
|
285
291
|
This can improve performance in some cases. Use it with caution because aliases and `@import` at-rules starting with `~` will not work.
|
|
286
292
|
|
|
@@ -308,6 +314,40 @@ module.exports = {
|
|
|
308
314
|
};
|
|
309
315
|
```
|
|
310
316
|
|
|
317
|
+
### `implementation`
|
|
318
|
+
|
|
319
|
+
Type: `Object`
|
|
320
|
+
|
|
321
|
+
> ⚠ less-loader compatible with Less 3 and 4 versions
|
|
322
|
+
|
|
323
|
+
The special `implementation` option determines which implementation of Less to use. Overrides the locally installed `peerDependency` version of `less`.
|
|
324
|
+
|
|
325
|
+
**This option is only really useful for downstream tooling authors to ease the Less 3-to-4 transition.**
|
|
326
|
+
|
|
327
|
+
**webpack.config.js**
|
|
328
|
+
|
|
329
|
+
```js
|
|
330
|
+
module.exports = {
|
|
331
|
+
module: {
|
|
332
|
+
rules: [
|
|
333
|
+
{
|
|
334
|
+
test: /\.less$/i,
|
|
335
|
+
use: [
|
|
336
|
+
"style-loader",
|
|
337
|
+
"css-loader",
|
|
338
|
+
{
|
|
339
|
+
loader: "less-loader",
|
|
340
|
+
options: {
|
|
341
|
+
implementation: require("less"),
|
|
342
|
+
},
|
|
343
|
+
},
|
|
344
|
+
],
|
|
345
|
+
},
|
|
346
|
+
],
|
|
347
|
+
},
|
|
348
|
+
};
|
|
349
|
+
```
|
|
350
|
+
|
|
311
351
|
## Examples
|
|
312
352
|
|
|
313
353
|
### Normal usage
|
|
@@ -321,7 +361,7 @@ module.exports = {
|
|
|
321
361
|
module: {
|
|
322
362
|
rules: [
|
|
323
363
|
{
|
|
324
|
-
test: /\.less
|
|
364
|
+
test: /\.less$/i,
|
|
325
365
|
use: [
|
|
326
366
|
{
|
|
327
367
|
loader: "style-loader", // creates style nodes from JS strings
|
|
@@ -347,13 +387,13 @@ To enable sourcemaps for CSS, you'll need to pass the `sourceMap` property in th
|
|
|
347
387
|
|
|
348
388
|
**webpack.config.js**
|
|
349
389
|
|
|
350
|
-
```
|
|
390
|
+
```js
|
|
351
391
|
module.exports = {
|
|
352
392
|
devtool: "source-map", // any "source-map"-like devtool is possible
|
|
353
393
|
module: {
|
|
354
394
|
rules: [
|
|
355
395
|
{
|
|
356
|
-
test: /\.less
|
|
396
|
+
test: /\.less$/i,
|
|
357
397
|
use: [
|
|
358
398
|
"style-loader",
|
|
359
399
|
{
|
|
@@ -383,21 +423,57 @@ Usually, it's recommended to extract the style sheets into a dedicated file in p
|
|
|
383
423
|
|
|
384
424
|
### Imports
|
|
385
425
|
|
|
386
|
-
|
|
426
|
+
First we try to use built-in `less` resolve logic, then `webpack` resolve logic (aliases and `~`).
|
|
387
427
|
|
|
388
|
-
####
|
|
428
|
+
#### Webpack Resolver
|
|
389
429
|
|
|
390
|
-
webpack provides an [advanced mechanism to resolve files](https://webpack.js.org/configuration/resolve/).
|
|
430
|
+
`webpack` provides an [advanced mechanism to resolve files](https://webpack.js.org/configuration/resolve/).
|
|
431
|
+
`less-loader` applies a Less plugin that passes all queries to the webpack resolver if `less` could not resolve `@import`.
|
|
432
|
+
Thus you can import your Less modules from `node_modules`.
|
|
433
|
+
|
|
434
|
+
```css
|
|
435
|
+
@import "bootstrap/less/bootstrap";
|
|
436
|
+
```
|
|
437
|
+
|
|
438
|
+
Using `~` is deprecated and can be removed from your code (**we recommend it**), but we still support it for historical reasons.
|
|
439
|
+
Why you can removed it? The loader will first try to resolve `@import` as relative, if it cannot be resolved, the loader will try to resolve `@import` inside [`node_modules`](https://webpack.js.org/configuration/resolve/#resolve-modules).
|
|
440
|
+
Just prepend them with a `~` which tells webpack to look up the [`modules`](https://webpack.js.org/configuration/resolve/#resolve-modules).
|
|
391
441
|
|
|
392
442
|
```css
|
|
393
443
|
@import "~bootstrap/less/bootstrap";
|
|
394
444
|
```
|
|
395
445
|
|
|
446
|
+
Default resolver options can be modified by [`resolve.byDependency`](https://webpack.js.org/configuration/resolve/#resolvebydependency):
|
|
447
|
+
|
|
448
|
+
**webpack.config.js**
|
|
449
|
+
|
|
450
|
+
```js
|
|
451
|
+
module.exports = {
|
|
452
|
+
devtool: "source-map", // any "source-map"-like devtool is possible
|
|
453
|
+
module: {
|
|
454
|
+
rules: [
|
|
455
|
+
{
|
|
456
|
+
test: /\.less$/i,
|
|
457
|
+
use: ["style-loader", "css-loader", "less-loader"],
|
|
458
|
+
},
|
|
459
|
+
],
|
|
460
|
+
},
|
|
461
|
+
resolve: {
|
|
462
|
+
byDependency: {
|
|
463
|
+
// More options can be found here https://webpack.js.org/configuration/resolve/
|
|
464
|
+
less: {
|
|
465
|
+
mainFiles: ["custom"],
|
|
466
|
+
},
|
|
467
|
+
},
|
|
468
|
+
},
|
|
469
|
+
};
|
|
470
|
+
```
|
|
471
|
+
|
|
396
472
|
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";`
|
|
397
473
|
|
|
398
|
-
#### Less
|
|
474
|
+
#### Less Resolver
|
|
399
475
|
|
|
400
|
-
If you specify the `paths` option, modules will be searched in the given `paths`. This is
|
|
476
|
+
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:
|
|
401
477
|
|
|
402
478
|
**webpack.config.js**
|
|
403
479
|
|
|
@@ -406,7 +482,7 @@ module.exports = {
|
|
|
406
482
|
module: {
|
|
407
483
|
rules: [
|
|
408
484
|
{
|
|
409
|
-
test: /\.less
|
|
485
|
+
test: /\.less$/i,
|
|
410
486
|
use: [
|
|
411
487
|
{
|
|
412
488
|
loader: "style-loader",
|
|
@@ -433,8 +509,9 @@ module.exports = {
|
|
|
433
509
|
|
|
434
510
|
In order to use [plugins](http://lesscss.org/usage/#plugins), simply set the `plugins` option like this:
|
|
435
511
|
|
|
512
|
+
**webpack.config.js**
|
|
513
|
+
|
|
436
514
|
```js
|
|
437
|
-
// webpack.config.js
|
|
438
515
|
const CleanCSSPlugin = require('less-plugin-clean-css');
|
|
439
516
|
|
|
440
517
|
module.exports = {
|
|
@@ -453,13 +530,13 @@ module.exports = {
|
|
|
453
530
|
};
|
|
454
531
|
```
|
|
455
532
|
|
|
456
|
-
> ℹ️ Access to the [loader context](https://webpack.js.org/api/loaders/#the-loader-context) inside the custom plugin can be done using the `
|
|
533
|
+
> ℹ️ Access to the [loader context](https://webpack.js.org/api/loaders/#the-loader-context) inside the custom plugin can be done using the `pluginManager.webpackLoaderContext` property.
|
|
457
534
|
|
|
458
535
|
```js
|
|
459
536
|
module.exports = {
|
|
460
537
|
install: function (less, pluginManager, functions) {
|
|
461
538
|
functions.add("pi", function () {
|
|
462
|
-
// Loader context is available in `
|
|
539
|
+
// Loader context is available in `pluginManager.webpackLoaderContext`
|
|
463
540
|
|
|
464
541
|
return Math.PI;
|
|
465
542
|
});
|
package/dist/index.js
CHANGED
|
@@ -9,10 +9,6 @@ var _path = _interopRequireDefault(require("path"));
|
|
|
9
9
|
|
|
10
10
|
var _less = _interopRequireDefault(require("less"));
|
|
11
11
|
|
|
12
|
-
var _loaderUtils = require("loader-utils");
|
|
13
|
-
|
|
14
|
-
var _schemaUtils = require("schema-utils");
|
|
15
|
-
|
|
16
12
|
var _options = _interopRequireDefault(require("./options.json"));
|
|
17
13
|
|
|
18
14
|
var _utils = require("./utils");
|
|
@@ -22,13 +18,12 @@ var _LessError = _interopRequireDefault(require("./LessError"));
|
|
|
22
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
19
|
|
|
24
20
|
async function lessLoader(source) {
|
|
25
|
-
const options =
|
|
26
|
-
(0, _schemaUtils.validate)(_options.default, options, {
|
|
27
|
-
name: "Less Loader",
|
|
28
|
-
baseDataPath: "options"
|
|
29
|
-
});
|
|
21
|
+
const options = this.getOptions(_options.default);
|
|
30
22
|
const callback = this.async();
|
|
31
|
-
const
|
|
23
|
+
const webpackContextSymbol = Symbol("loaderContext");
|
|
24
|
+
const lessOptions = (0, _utils.getLessOptions)(this, { ...options,
|
|
25
|
+
webpackContextSymbol
|
|
26
|
+
});
|
|
32
27
|
const useSourceMap = typeof options.sourceMap === "boolean" ? options.sourceMap : this.sourceMap;
|
|
33
28
|
|
|
34
29
|
if (useSourceMap) {
|
|
@@ -46,7 +41,7 @@ async function lessLoader(source) {
|
|
|
46
41
|
let result;
|
|
47
42
|
|
|
48
43
|
try {
|
|
49
|
-
result = await _less.default.render(data, lessOptions);
|
|
44
|
+
result = await (options.implementation || _less.default).render(data, lessOptions);
|
|
50
45
|
} catch (error) {
|
|
51
46
|
if (error.filename) {
|
|
52
47
|
// `less` returns forward slashes on windows when `webpack` resolver return an absolute windows path in `WebpackFileManager`
|
|
@@ -58,6 +53,7 @@ async function lessLoader(source) {
|
|
|
58
53
|
return;
|
|
59
54
|
}
|
|
60
55
|
|
|
56
|
+
delete _less.default[webpackContextSymbol];
|
|
61
57
|
const {
|
|
62
58
|
css,
|
|
63
59
|
imports
|
package/dist/options.json
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
+
"title": "Less Loader options",
|
|
2
3
|
"type": "object",
|
|
3
4
|
"properties": {
|
|
4
5
|
"lessOptions": {
|
|
@@ -31,6 +32,10 @@
|
|
|
31
32
|
"webpackImporter": {
|
|
32
33
|
"description": "Enables/Disables default `webpack` importer (https://github.com/webpack-contrib/less-loader#webpackimporter).",
|
|
33
34
|
"type": "boolean"
|
|
35
|
+
},
|
|
36
|
+
"implementation": {
|
|
37
|
+
"description": "The implementation of the `Less` to be used (https://github.com/webpack-contrib/less-loader#implementation).",
|
|
38
|
+
"type": "object"
|
|
34
39
|
}
|
|
35
40
|
},
|
|
36
41
|
"additionalProperties": false
|
package/dist/utils.js
CHANGED
|
@@ -9,12 +9,12 @@ exports.normalizeSourceMap = normalizeSourceMap;
|
|
|
9
9
|
|
|
10
10
|
var _path = _interopRequireDefault(require("path"));
|
|
11
11
|
|
|
12
|
+
var _util = _interopRequireDefault(require("util"));
|
|
13
|
+
|
|
12
14
|
var _less = _interopRequireDefault(require("less"));
|
|
13
15
|
|
|
14
16
|
var _full = require("klona/full");
|
|
15
17
|
|
|
16
|
-
var _loaderUtils = require("loader-utils");
|
|
17
|
-
|
|
18
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
19
|
|
|
20
20
|
/* eslint-disable class-methods-use-this */
|
|
@@ -24,7 +24,16 @@ const trailingSlash = /[/\\]$/; // This somewhat changed in Less 3.x. Now the fi
|
|
|
24
24
|
|
|
25
25
|
const IS_SPECIAL_MODULE_IMPORT = /^~[^/]+$/; // `[drive_letter]:\` + `\\[server]\[sharename]\`
|
|
26
26
|
|
|
27
|
-
const IS_NATIVE_WIN32_PATH = /^[a-z]:[/\\]|^\\\\/i;
|
|
27
|
+
const IS_NATIVE_WIN32_PATH = /^[a-z]:[/\\]|^\\\\/i; // Examples:
|
|
28
|
+
// - ~package
|
|
29
|
+
// - ~package/
|
|
30
|
+
// - ~@org
|
|
31
|
+
// - ~@org/
|
|
32
|
+
// - ~@org/package
|
|
33
|
+
// - ~@org/package/
|
|
34
|
+
|
|
35
|
+
const IS_MODULE_IMPORT = /^~([^/]+|[^/]+\/|@[^/]+[/][^/]+|@[^/]+\/?|@[^/]+[/][^/]+\/)$/;
|
|
36
|
+
const MODULE_REQUEST_REGEX = /^[^?]*~/;
|
|
28
37
|
/**
|
|
29
38
|
* Creates a Less plugin that uses webpack's resolving engine that is provided by the loaderContext.
|
|
30
39
|
*
|
|
@@ -34,10 +43,12 @@ const IS_NATIVE_WIN32_PATH = /^[a-z]:[/\\]|^\\\\/i;
|
|
|
34
43
|
|
|
35
44
|
function createWebpackLessPlugin(loaderContext) {
|
|
36
45
|
const resolve = loaderContext.getResolve({
|
|
46
|
+
dependencyType: "less",
|
|
37
47
|
conditionNames: ["less", "style"],
|
|
38
48
|
mainFields: ["less", "style", "main", "..."],
|
|
39
49
|
mainFiles: ["index", "..."],
|
|
40
|
-
extensions: [".less", ".css"]
|
|
50
|
+
extensions: [".less", ".css"],
|
|
51
|
+
preferRelative: true
|
|
41
52
|
});
|
|
42
53
|
|
|
43
54
|
class WebpackFileManager extends _less.default.FileManager {
|
|
@@ -65,25 +76,39 @@ function createWebpackLessPlugin(loaderContext) {
|
|
|
65
76
|
async resolveFilename(filename, currentDirectory) {
|
|
66
77
|
// Less is giving us trailing slashes, but the context should have no trailing slash
|
|
67
78
|
const context = currentDirectory.replace(trailingSlash, "");
|
|
68
|
-
|
|
69
|
-
|
|
79
|
+
let request = filename; // A `~` makes the url an module
|
|
80
|
+
|
|
81
|
+
if (MODULE_REQUEST_REGEX.test(filename)) {
|
|
82
|
+
request = request.replace(MODULE_REQUEST_REGEX, "");
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (IS_MODULE_IMPORT.test(filename)) {
|
|
86
|
+
request = request[request.length - 1] === "/" ? request : `${request}/`;
|
|
87
|
+
}
|
|
88
|
+
|
|
70
89
|
return this.resolveRequests(context, [...new Set([request, filename])]);
|
|
71
90
|
}
|
|
72
91
|
|
|
73
|
-
resolveRequests(context, possibleRequests) {
|
|
92
|
+
async resolveRequests(context, possibleRequests) {
|
|
74
93
|
if (possibleRequests.length === 0) {
|
|
75
94
|
return Promise.reject();
|
|
76
95
|
}
|
|
77
96
|
|
|
78
|
-
|
|
97
|
+
let result;
|
|
98
|
+
|
|
99
|
+
try {
|
|
100
|
+
result = await resolve(context, possibleRequests[0]);
|
|
101
|
+
} catch (error) {
|
|
79
102
|
const [, ...tailPossibleRequests] = possibleRequests;
|
|
80
103
|
|
|
81
104
|
if (tailPossibleRequests.length === 0) {
|
|
82
105
|
throw error;
|
|
83
106
|
}
|
|
84
107
|
|
|
85
|
-
|
|
86
|
-
}
|
|
108
|
+
result = await this.resolveRequests(context, tailPossibleRequests);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return result;
|
|
87
112
|
}
|
|
88
113
|
|
|
89
114
|
async loadFile(filename, ...args) {
|
|
@@ -152,9 +177,25 @@ function getLessOptions(loaderContext, loaderOptions) {
|
|
|
152
177
|
}
|
|
153
178
|
|
|
154
179
|
lessOptions.plugins.unshift({
|
|
155
|
-
install(lessProcessor) {
|
|
180
|
+
install(lessProcessor, pluginManager) {
|
|
156
181
|
// eslint-disable-next-line no-param-reassign
|
|
157
|
-
|
|
182
|
+
pluginManager.webpackLoaderContext = loaderContext; // Todo remove in next major release `lessProcessor[webpackContextSymbol]`
|
|
183
|
+
|
|
184
|
+
const {
|
|
185
|
+
webpackContextSymbol
|
|
186
|
+
} = options; // eslint-disable-next-line no-param-reassign
|
|
187
|
+
|
|
188
|
+
lessProcessor[webpackContextSymbol] = loaderContext;
|
|
189
|
+
Object.defineProperty(lessProcessor, "webpackLoaderContext", {
|
|
190
|
+
configurable: true,
|
|
191
|
+
|
|
192
|
+
get() {
|
|
193
|
+
_util.default.deprecate(() => {}, "less.webpackLoaderContext is deprecated and will be removed in next major release. Instead use pluginManager.webpackLoaderContext (https://webpack.js.org/loaders/less-loader/#plugins)")();
|
|
194
|
+
|
|
195
|
+
return lessProcessor[webpackContextSymbol];
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
});
|
|
158
199
|
}
|
|
159
200
|
|
|
160
201
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "less-loader",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.1.1",
|
|
4
4
|
"description": "A Less loader for webpack. Compiles Less to CSS.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "webpack-contrib/less-loader",
|
|
@@ -31,47 +31,42 @@
|
|
|
31
31
|
"pretest": "npm run lint",
|
|
32
32
|
"test": "npm run test:coverage",
|
|
33
33
|
"prepare": "npm run build",
|
|
34
|
-
"release": "standard-version"
|
|
35
|
-
"defaults": "webpack-defaults"
|
|
34
|
+
"release": "standard-version"
|
|
36
35
|
},
|
|
37
36
|
"files": [
|
|
38
37
|
"dist"
|
|
39
38
|
],
|
|
40
39
|
"peerDependencies": {
|
|
41
40
|
"less": "^3.5.0 || ^4.0.0",
|
|
42
|
-
"webpack": "^
|
|
41
|
+
"webpack": "^5.0.0"
|
|
43
42
|
},
|
|
44
43
|
"dependencies": {
|
|
45
|
-
"klona": "^2.0.4"
|
|
46
|
-
"loader-utils": "^2.0.0",
|
|
47
|
-
"schema-utils": "^3.0.0"
|
|
44
|
+
"klona": "^2.0.4"
|
|
48
45
|
},
|
|
49
46
|
"devDependencies": {
|
|
50
|
-
"@babel/cli": "^7.
|
|
51
|
-
"@babel/core": "^7.
|
|
52
|
-
"@babel/preset-env": "^7.
|
|
53
|
-
"@commitlint/cli": "^
|
|
54
|
-
"@commitlint/config-conventional": "^
|
|
55
|
-
"@webpack-contrib/defaults": "^6.3.0",
|
|
47
|
+
"@babel/cli": "^7.13.14",
|
|
48
|
+
"@babel/core": "^7.13.15",
|
|
49
|
+
"@babel/preset-env": "^7.13.15",
|
|
50
|
+
"@commitlint/cli": "^12.1.1",
|
|
51
|
+
"@commitlint/config-conventional": "^12.1.1",
|
|
56
52
|
"@webpack-contrib/eslint-config-webpack": "^3.0.0",
|
|
57
53
|
"babel-jest": "^26.6.3",
|
|
58
54
|
"cross-env": "^7.0.3",
|
|
59
55
|
"del": "^6.0.0",
|
|
60
56
|
"del-cli": "^3.0.1",
|
|
61
|
-
"eslint": "^7.
|
|
62
|
-
"eslint-config-prettier": "^
|
|
57
|
+
"eslint": "^7.24.0",
|
|
58
|
+
"eslint-config-prettier": "^8.2.0",
|
|
63
59
|
"eslint-plugin-import": "^2.22.1",
|
|
64
|
-
"
|
|
65
|
-
"husky": "^4.3.6",
|
|
60
|
+
"husky": "^4.3.8",
|
|
66
61
|
"jest": "^26.6.3",
|
|
67
|
-
"less": "^4.
|
|
68
|
-
"lint-staged": "^10.5.
|
|
69
|
-
"memfs": "^3.2.
|
|
62
|
+
"less": "^4.1.1",
|
|
63
|
+
"lint-staged": "^10.5.4",
|
|
64
|
+
"memfs": "^3.2.2",
|
|
70
65
|
"npm-run-all": "^4.1.5",
|
|
71
66
|
"prettier": "^2.2.1",
|
|
72
|
-
"standard-version": "^9.
|
|
67
|
+
"standard-version": "^9.2.0",
|
|
73
68
|
"strip-ansi": "^6.0.0",
|
|
74
|
-
"webpack": "^5.
|
|
69
|
+
"webpack": "^5.33.2"
|
|
75
70
|
},
|
|
76
71
|
"keywords": [
|
|
77
72
|
"webpack",
|