less-loader 11.1.4 → 12.1.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/README.md CHANGED
@@ -66,6 +66,7 @@ And run `webpack` via your preferred method.
66
66
  - **[`sourceMap`](#sourcemap)**
67
67
  - **[`webpackImporter`](#webpackimporter)**
68
68
  - **[`implementation`](#implementation)**
69
+ - **[`lessLogAsWarnOrErr`](#lesslogaswarnorerr)**
69
70
 
70
71
  ### `lessOptions`
71
72
 
@@ -411,6 +412,52 @@ module.exports = {
411
412
  };
412
413
  ```
413
414
 
415
+ ### `lessLogAsWarnOrErr`
416
+
417
+ Type:
418
+
419
+ ```ts
420
+ type lessLogAsWarnOrErr = boolean;
421
+ ```
422
+
423
+ Default: `false`
424
+
425
+ `Less` warnings and errors will be webpack warnings and errors, not just logs.
426
+
427
+ **warning.less**
428
+
429
+ ```less
430
+ div {
431
+ &:extend(.body1);
432
+ }
433
+ ```
434
+
435
+ If `lessLogAsWarnOrErr` is set to `false` it will be just a log and webpack will compile successfully, but if you set this option to `true` webpack will compile fail with a warning.
436
+
437
+ **webpack.config.js**
438
+
439
+ ```js
440
+ module.exports = {
441
+ module: {
442
+ rules: [
443
+ {
444
+ test: /\.less$/i,
445
+ use: [
446
+ "style-loader",
447
+ "css-loader",
448
+ {
449
+ loader: "less-loader",
450
+ options: {
451
+ lessLogAsWarnOrErr: true,
452
+ },
453
+ },
454
+ ],
455
+ },
456
+ ],
457
+ },
458
+ };
459
+ ```
460
+
414
461
  ## Examples
415
462
 
416
463
  ### Normal usage
package/dist/index.js CHANGED
@@ -34,12 +34,23 @@ async function lessLoader(source) {
34
34
  data = typeof options.additionalData === "function" ? `${await options.additionalData(data, this)}` : `${options.additionalData}\n${data}`;
35
35
  }
36
36
  const logger = this.getLogger("less-loader");
37
+ const loaderContext = this;
37
38
  const loggerListener = {
38
39
  error(message) {
39
- logger.error(message);
40
+ // TODO enable by default in the next major release
41
+ if (options.lessLogAsWarnOrErr) {
42
+ loaderContext.emitError(new Error(message));
43
+ } else {
44
+ logger.error(message);
45
+ }
40
46
  },
41
47
  warn(message) {
42
- logger.warn(message);
48
+ // TODO enable by default in the next major release
49
+ if (options.lessLogAsWarnOrErr) {
50
+ loaderContext.emitWarning(new Error(message));
51
+ } else {
52
+ logger.warn(message);
53
+ }
43
54
  },
44
55
  info(message) {
45
56
  logger.log(message);
@@ -90,5 +101,4 @@ async function lessLoader(source) {
90
101
  }
91
102
  callback(null, css, map);
92
103
  }
93
- var _default = lessLoader;
94
- exports.default = _default;
104
+ var _default = exports.default = lessLoader;
package/dist/options.json CHANGED
@@ -48,6 +48,11 @@
48
48
  "type": "object"
49
49
  }
50
50
  ]
51
+ },
52
+ "lessLogAsWarnOrErr": {
53
+ "description": "Less warnings and errors will be webpack warnings or errors.",
54
+ "link": "https://github.com/webpack-contrib/less-loader#lesslogaswarnorerr",
55
+ "type": "boolean"
51
56
  }
52
57
  },
53
58
  "additionalProperties": false
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "less-loader",
3
- "version": "11.1.4",
3
+ "version": "12.1.0",
4
4
  "description": "A Less loader for webpack. Compiles Less to CSS.",
5
5
  "license": "MIT",
6
6
  "repository": "webpack-contrib/less-loader",
@@ -13,7 +13,7 @@
13
13
  },
14
14
  "main": "dist/cjs.js",
15
15
  "engines": {
16
- "node": ">= 14.15.0"
16
+ "node": ">= 18.12.0"
17
17
  },
18
18
  "scripts": {
19
19
  "start": "npm run build -- -w",
@@ -22,9 +22,9 @@
22
22
  "build": "cross-env NODE_ENV=production babel src -d dist --copy-files",
23
23
  "commitlint": "commitlint --from=master",
24
24
  "security": "npm audit --production",
25
- "lint:prettier": "prettier --list-different .",
25
+ "lint:prettier": "prettier --cache --list-different .",
26
26
  "lint:js": "eslint --cache .",
27
- "lint:spelling": "cspell \"**/*.*\"",
27
+ "lint:spelling": "cspell --cache --no-must-find-files --quiet \"**/*.*\"",
28
28
  "lint": "npm-run-all -l -p \"lint:**\"",
29
29
  "fix:js": "npm run lint:js -- --fix",
30
30
  "fix:prettier": "npm run lint:prettier -- --write",
@@ -45,31 +45,31 @@
45
45
  "webpack": "^5.0.0"
46
46
  },
47
47
  "devDependencies": {
48
- "@babel/cli": "^7.23.0",
49
- "@babel/core": "^7.23.0",
50
- "@babel/preset-env": "^7.22.20",
51
- "@commitlint/cli": "^17.7.2",
52
- "@commitlint/config-conventional": "^17.7.0",
48
+ "@babel/cli": "^7.23.4",
49
+ "@babel/core": "^7.23.7",
50
+ "@babel/preset-env": "^7.23.7",
51
+ "@commitlint/cli": "^18.4.4",
52
+ "@commitlint/config-conventional": "^18.4.4",
53
53
  "@webpack-contrib/eslint-config-webpack": "^3.0.0",
54
54
  "babel-jest": "^29.7.0",
55
55
  "cross-env": "^7.0.3",
56
- "cspell": "^6.31.2",
57
- "del": "^6.1.1",
58
- "del-cli": "^4.0.1",
59
- "eslint": "^8.50.0",
60
- "eslint-config-prettier": "^8.9.0",
61
- "eslint-plugin-import": "^2.28.1",
56
+ "cspell": "^8.3.2",
57
+ "del": "^7.1.0",
58
+ "del-cli": "^5.1.0",
59
+ "eslint": "^8.56.0",
60
+ "eslint-config-prettier": "^9.1.0",
61
+ "eslint-plugin-import": "^2.29.1",
62
62
  "husky": "^8.0.3",
63
63
  "jest": "^29.7.0",
64
64
  "less": "^4.2.0",
65
- "less-plugin-glob": "^2.0.2",
66
- "lint-staged": "^13.2.3",
67
- "memfs": "^3.5.1",
65
+ "less-plugin-glob": "^3.0.0",
66
+ "lint-staged": "^15.2.0",
67
+ "memfs": "^4.6.0",
68
68
  "npm-run-all": "^4.1.5",
69
- "prettier": "^2.8.8",
69
+ "prettier": "^3.2.2",
70
70
  "standard-version": "^9.3.1",
71
71
  "strip-ansi": "^7.1.0",
72
- "webpack": "^5.88.2"
72
+ "webpack": "^5.89.0"
73
73
  },
74
74
  "keywords": [
75
75
  "webpack",