less-loader 10.2.0 → 11.0.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.
Files changed (2) hide show
  1. package/README.md +62 -26
  2. package/package.json +9 -9
package/README.md CHANGED
@@ -21,7 +21,19 @@ A Less loader for webpack. Compiles Less to CSS.
21
21
  To begin, you'll need to install `less` and `less-loader`:
22
22
 
23
23
  ```console
24
- $ npm install less less-loader --save-dev
24
+ npm install less less-loader --save-dev
25
+ ```
26
+
27
+ or
28
+
29
+ ```console
30
+ yarn add -D less less-loader
31
+ ```
32
+
33
+ or
34
+
35
+ ```console
36
+ pnpm add -D less less-loader
25
37
  ```
26
38
 
27
39
  Then add the loader to your `webpack` config. For example:
@@ -34,7 +46,7 @@ module.exports = {
34
46
  rules: [
35
47
  {
36
48
  test: /\.less$/i,
37
- loader: [
49
+ use: [
38
50
  // compiles Less to CSS
39
51
  "style-loader",
40
52
  "css-loader",
@@ -50,22 +62,25 @@ And run `webpack` via your preferred method.
50
62
 
51
63
  ## Options
52
64
 
53
- | Name | Type | Default | Description |
54
- | :---------------------------------------: | :------------------: | :----------------------: | :----------------------------------------------------- |
55
- | **[`lessOptions`](#lessoptions)** | `{Object\|Function}` | `{ relativeUrls: true }` | Options for Less. |
56
- | **[`additionalData`](#additionalData)** | `{String\|Function}` | `undefined` | Prepends/Appends `Less` code to the actual entry file. |
57
- | **[`sourceMap`](#sourcemap)** | `{Boolean}` | `compiler.devtool` | Enables/Disables generation of source maps. |
58
- | **[`webpackImporter`](#webpackimporter)** | `{Boolean}` | `true` | Enables/Disables the default Webpack importer. |
59
- | **[`implementation`](#implementation)** | `{Object\|String}` | `less` | Setup Less implementation to use. |
65
+ - **[`lessOptions`](#lessoptions)**
66
+ - **[`additionalData`](#additionalData)**
67
+ - **[`sourceMap`](#sourcemap)**
68
+ - **[`webpackImporter`](#webpackimporter)**
69
+ - **[`implementation`](#implementation)**
60
70
 
61
71
  ### `lessOptions`
62
72
 
63
- Type: `Object|Function`
73
+ Type:
74
+
75
+ ```ts
76
+ type lessOptions = import('less').options | ((loaderContext: LoaderContext) => import('less').options})
77
+ ```
78
+
64
79
  Default: `{ relativeUrls: true }`
65
80
 
66
81
  You can pass any Less specific options to the `less-loader` through the `lessOptions` property in the [loader options](https://webpack.js.org/configuration/module/#rule-options-rule-query). See the [Less documentation](http://lesscss.org/usage/#command-line-usage-options) for all available options in dash-case. Since we're passing these options to Less programmatically, you need to pass them in camelCase here:
67
82
 
68
- #### `Object`
83
+ #### `object`
69
84
 
70
85
  Use an object to pass options through to Less.
71
86
 
@@ -99,7 +114,7 @@ module.exports = {
99
114
  };
100
115
  ```
101
116
 
102
- #### `Function`
117
+ #### `function`
103
118
 
104
119
  Allows setting the options passed through to Less based off of the loader context.
105
120
 
@@ -141,17 +156,24 @@ module.exports = {
141
156
 
142
157
  ### `additionalData`
143
158
 
144
- Type: `String|Function`
159
+ Type:
160
+
161
+ ```ts
162
+ type additionalData =
163
+ | string
164
+ | ((content: string, loaderContext: LoaderContext) => string);
165
+ ```
166
+
145
167
  Default: `undefined`
146
168
 
147
- Prepends `Less` code before the actual entry file.
169
+ Prepends/Appends `Less` code to the actual entry file.
148
170
  In this case, the `less-loader` will not override the source but just **prepend** the entry's content.
149
171
 
150
172
  This is especially useful when some of your Less variables depend on the environment:
151
173
 
152
- > ℹ Since you're injecting code, this will break the source mappings in your entry file. Often there's a simpler solution than this, like multiple Less entry files.
174
+ > Since you're injecting code, this will break the source mappings in your entry file. Often there's a simpler solution than this, like multiple Less entry files.
153
175
 
154
- #### `String`
176
+ #### `string`
155
177
 
156
178
  ```js
157
179
  module.exports = {
@@ -175,9 +197,9 @@ module.exports = {
175
197
  };
176
198
  ```
177
199
 
178
- #### `Function`
200
+ #### `function`
179
201
 
180
- ##### Sync
202
+ ##### `Sync`
181
203
 
182
204
  ```js
183
205
  module.exports = {
@@ -211,7 +233,7 @@ module.exports = {
211
233
  };
212
234
  ```
213
235
 
214
- ##### Async
236
+ ##### `Async`
215
237
 
216
238
  ```js
217
239
  module.exports = {
@@ -247,7 +269,12 @@ module.exports = {
247
269
 
248
270
  ### `sourceMap`
249
271
 
250
- Type: `Boolean`
272
+ Type:
273
+
274
+ ```ts
275
+ type sourceMap = boolean;
276
+ ```
277
+
251
278
  Default: depends on the `compiler.devtool` value
252
279
 
253
280
  By default generation of source maps depends on the [`devtool`](https://webpack.js.org/configuration/devtool/) option. All values enable source map generation except `eval` and `false` value.
@@ -283,7 +310,12 @@ module.exports = {
283
310
 
284
311
  ### `webpackImporter`
285
312
 
286
- Type: `Boolean`
313
+ Type:
314
+
315
+ ```ts
316
+ type webpackImporter = boolean;
317
+ ```
318
+
287
319
  Default: `true`
288
320
 
289
321
  Enables/Disables the default `webpack` importer.
@@ -316,15 +348,19 @@ module.exports = {
316
348
 
317
349
  ### `implementation`
318
350
 
319
- Type: `Object | String`
351
+ Type:
352
+
353
+ ```ts
354
+ type implementation = object | string;
355
+ ```
320
356
 
321
- > ⚠ less-loader compatible with Less 3 and 4 versions
357
+ > less-loader compatible with Less 3 and 4 versions
322
358
 
323
359
  The special `implementation` option determines which implementation of Less to use. Overrides the locally installed `peerDependency` version of `less`.
324
360
 
325
361
  **This option is only really useful for downstream tooling authors to ease the Less 3-to-4 transition.**
326
362
 
327
- #### Object
363
+ #### `object`
328
364
 
329
365
  **webpack.config.js**
330
366
 
@@ -350,7 +386,7 @@ module.exports = {
350
386
  };
351
387
  ```
352
388
 
353
- #### String
389
+ #### `string`
354
390
 
355
391
  **webpack.config.js**
356
392
 
@@ -579,7 +615,7 @@ Bundling CSS with webpack has some nice advantages like referencing images and f
579
615
  There are two possibilities to extract a style sheet from the bundle:
580
616
 
581
617
  - [`extract-loader`](https://github.com/peerigon/extract-loader) (simpler, but specialized on the css-loader's output)
582
- - [MiniCssExtractPlugin](https://github.com/webpack-contrib/mini-css-extract-plugin) (more complex, but works in all use-cases)
618
+ - [`MiniCssExtractPlugin`](https://github.com/webpack-contrib/mini-css-extract-plugin) (more complex, but works in all use-cases)
583
619
 
584
620
  ### CSS modules gotcha
585
621
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "less-loader",
3
- "version": "10.2.0",
3
+ "version": "11.0.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": ">= 12.13.0"
16
+ "node": ">= 14.15.0"
17
17
  },
18
18
  "scripts": {
19
19
  "start": "npm run build -- -w",
@@ -47,21 +47,21 @@
47
47
  "@babel/cli": "^7.14.5",
48
48
  "@babel/core": "^7.14.6",
49
49
  "@babel/preset-env": "^7.14.7",
50
- "@commitlint/cli": "^13.1.0",
51
- "@commitlint/config-conventional": "^13.1.0",
50
+ "@commitlint/cli": "^17.0.0",
51
+ "@commitlint/config-conventional": "^17.0.0",
52
52
  "@webpack-contrib/eslint-config-webpack": "^3.0.0",
53
- "babel-jest": "^27.0.6",
53
+ "babel-jest": "^28.1.0",
54
54
  "cross-env": "^7.0.3",
55
55
  "del": "^6.0.0",
56
56
  "del-cli": "^4.0.1",
57
- "eslint": "^7.30.0",
57
+ "eslint": "^8.15.0",
58
58
  "eslint-config-prettier": "^8.3.0",
59
59
  "eslint-plugin-import": "^2.24.1",
60
- "husky": "^7.0.1",
61
- "jest": "^27.0.6",
60
+ "husky": "^8.0.1",
61
+ "jest": "^28.1.0",
62
62
  "less": "^4.1.1",
63
63
  "less-plugin-glob": "^3.0.0",
64
- "lint-staged": "^11.0.1",
64
+ "lint-staged": "^12.4.1",
65
65
  "memfs": "^3.2.2",
66
66
  "npm-run-all": "^4.1.5",
67
67
  "prettier": "^2.3.2",