less-loader 6.0.0 → 6.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/CHANGELOG.md +12 -0
- package/README.md +44 -0
- package/dist/index.js +2 -6
- package/dist/options.json +5 -1
- package/dist/utils.js +13 -4
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,18 @@
|
|
|
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.1.0](https://github.com/webpack-contrib/less-loader/compare/v6.0.0...v6.1.0) (2020-05-07)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* new `implementation` option ([#354](https://github.com/webpack-contrib/less-loader/issues/354)) ([d2de80f](https://github.com/webpack-contrib/less-loader/commit/d2de80f9fe6ee11e784260dbda960853ebd2449b))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* respect third-party plugins for `Less` ([#353](https://github.com/webpack-contrib/less-loader/issues/353)) ([d0db4f9](https://github.com/webpack-contrib/less-loader/commit/d0db4f9839c4921440c9a0fdc00fd00bc5a6fbb8))
|
|
16
|
+
|
|
5
17
|
## [6.0.0](https://github.com/webpack-contrib/less-loader/compare/v5.0.0...v6.0.0) (2020-04-24)
|
|
6
18
|
|
|
7
19
|
|
package/README.md
CHANGED
|
@@ -45,9 +45,18 @@ And run `webpack` via your preferred method.
|
|
|
45
45
|
|
|
46
46
|
## Options
|
|
47
47
|
|
|
48
|
+
| Name | Type | Default | Description |
|
|
49
|
+
| :-------------------------------------: | :------------------: | :----------------------: | :----------------------------------------------- |
|
|
50
|
+
| **[`lessOptions`](#lessoptions)** | `{Object\|Function}` | `{ relativeUrls: true }` | Options for Less. |
|
|
51
|
+
| **[`prependData`](#prependdata)** | `{String\|Function}` | `undefined` | Prepends Less code before the actual entry file. |
|
|
52
|
+
| **[`appendData`](#appenddata)** | `{String\|Function}` | `undefined` | Prepends Less code after the actual entry file. |
|
|
53
|
+
| **[`sourceMap`](#sourcemap)** | `{Boolean}` | `compiler.devtool` | Enables/Disables generation of source maps. |
|
|
54
|
+
| **[`implementation`](#implementation)** | `{Object}` | `less` | Setup Less implementation to use. |
|
|
55
|
+
|
|
48
56
|
### `lessOptions`
|
|
49
57
|
|
|
50
58
|
Type: `Object|Function`
|
|
59
|
+
Default: `{ relativeUrls: true }`
|
|
51
60
|
|
|
52
61
|
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:
|
|
53
62
|
|
|
@@ -299,6 +308,41 @@ module.exports = {
|
|
|
299
308
|
};
|
|
300
309
|
```
|
|
301
310
|
|
|
311
|
+
### `implementation`
|
|
312
|
+
|
|
313
|
+
Type: `Object`
|
|
314
|
+
Default: `less`
|
|
315
|
+
|
|
316
|
+
> ⚠ less-loader compatible with Less version 3 only
|
|
317
|
+
|
|
318
|
+
The special `implementation` option determines which implementation of Less to use.
|
|
319
|
+
The `implementation` options either accepts `less` as a module.
|
|
320
|
+
This is useful if you want to use Less with a smaller version. Do not forget that then you must install your own version of Less.
|
|
321
|
+
|
|
322
|
+
For example, to use custom Less implementation, you'd pass:
|
|
323
|
+
|
|
324
|
+
```js
|
|
325
|
+
module.exports = {
|
|
326
|
+
module: {
|
|
327
|
+
rules: [
|
|
328
|
+
{
|
|
329
|
+
test: /\.less$/,
|
|
330
|
+
use: [
|
|
331
|
+
'style-loader',
|
|
332
|
+
'css-loader',
|
|
333
|
+
{
|
|
334
|
+
loader: 'less-loader',
|
|
335
|
+
options: {
|
|
336
|
+
implementation: require('less'),
|
|
337
|
+
},
|
|
338
|
+
},
|
|
339
|
+
],
|
|
340
|
+
},
|
|
341
|
+
],
|
|
342
|
+
},
|
|
343
|
+
};
|
|
344
|
+
```
|
|
345
|
+
|
|
302
346
|
## Examples
|
|
303
347
|
|
|
304
348
|
### Normal usage
|
package/dist/index.js
CHANGED
|
@@ -5,8 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
-
var _less = _interopRequireDefault(require("less"));
|
|
9
|
-
|
|
10
8
|
var _loaderUtils = require("loader-utils");
|
|
11
9
|
|
|
12
10
|
var _schemaUtils = _interopRequireDefault(require("schema-utils"));
|
|
@@ -37,14 +35,12 @@ function lessLoader(source) {
|
|
|
37
35
|
data = typeof options.appendData === 'function' ? `${data}\n${options.appendData(this)}` : `${data}\n${options.appendData}`;
|
|
38
36
|
}
|
|
39
37
|
|
|
40
|
-
|
|
38
|
+
(0, _utils.getLessImplementation)(options.implementation).render(data, lessOptions).then(({
|
|
41
39
|
css,
|
|
42
40
|
map,
|
|
43
41
|
imports
|
|
44
42
|
}) => {
|
|
45
|
-
imports.forEach(this.addDependency, this);
|
|
46
|
-
// See removeSourceMappingUrl.js for the reasoning behind this.
|
|
47
|
-
|
|
43
|
+
imports.forEach(this.addDependency, this);
|
|
48
44
|
callback(null, css, typeof map === 'string' ? JSON.parse(map) : map);
|
|
49
45
|
}).catch(lessError => {
|
|
50
46
|
if (lessError.filename) {
|
package/dist/options.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"type": "object",
|
|
3
3
|
"properties": {
|
|
4
4
|
"lessOptions": {
|
|
5
|
-
"description": "Options to pass through to `
|
|
5
|
+
"description": "Options to pass through to `Less` (https://github.com/webpack-contrib/less-loader#lessoptions).",
|
|
6
6
|
"anyOf": [
|
|
7
7
|
{
|
|
8
8
|
"type": "object",
|
|
@@ -38,6 +38,10 @@
|
|
|
38
38
|
"sourceMap": {
|
|
39
39
|
"description": "Enables/Disables generation of source maps (https://github.com/webpack-contrib/less-loader#sourcemap).",
|
|
40
40
|
"type": "boolean"
|
|
41
|
+
},
|
|
42
|
+
"implementation": {
|
|
43
|
+
"description": "The implementation of the `Less` to be used (https://github.com/webpack-contrib/less-loader#implementation).",
|
|
44
|
+
"type": "object"
|
|
41
45
|
}
|
|
42
46
|
},
|
|
43
47
|
"additionalProperties": false
|
package/dist/utils.js
CHANGED
|
@@ -3,12 +3,13 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.getLessImplementation = getLessImplementation;
|
|
6
7
|
exports.getLessOptions = getLessOptions;
|
|
7
8
|
|
|
8
|
-
var _clone = _interopRequireDefault(require("clone"));
|
|
9
|
-
|
|
10
9
|
var _less = _interopRequireDefault(require("less"));
|
|
11
10
|
|
|
11
|
+
var _clone = _interopRequireDefault(require("clone"));
|
|
12
|
+
|
|
12
13
|
var _loaderUtils = require("loader-utils");
|
|
13
14
|
|
|
14
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -144,7 +145,7 @@ function getLessOptions(loaderContext, loaderOptions) {
|
|
|
144
145
|
filename: loaderContext.resourcePath,
|
|
145
146
|
...options
|
|
146
147
|
};
|
|
147
|
-
lessOptions.plugins.
|
|
148
|
+
lessOptions.plugins.unshift(createWebpackLessPlugin(loaderContext));
|
|
148
149
|
const useSourceMap = typeof loaderOptions.sourceMap === 'boolean' ? loaderOptions.sourceMap : loaderContext.sourceMap;
|
|
149
150
|
|
|
150
151
|
if (useSourceMap) {
|
|
@@ -154,4 +155,12 @@ function getLessOptions(loaderContext, loaderOptions) {
|
|
|
154
155
|
}
|
|
155
156
|
|
|
156
157
|
return lessOptions;
|
|
157
|
-
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function getLessImplementation(implementation) {
|
|
161
|
+
if (typeof implementation !== 'undefined') {
|
|
162
|
+
return implementation;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
return _less.default;
|
|
166
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "less-loader",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.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",
|
|
@@ -48,13 +48,13 @@
|
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@babel/cli": "^7.8.4",
|
|
51
|
-
"@babel/core": "^7.9.
|
|
52
|
-
"@babel/preset-env": "^7.9.
|
|
51
|
+
"@babel/core": "^7.9.6",
|
|
52
|
+
"@babel/preset-env": "^7.9.6",
|
|
53
53
|
"@commitlint/cli": "^8.3.5",
|
|
54
54
|
"@commitlint/config-conventional": "^8.3.4",
|
|
55
55
|
"@webpack-contrib/defaults": "^6.3.0",
|
|
56
56
|
"@webpack-contrib/eslint-config-webpack": "^3.0.0",
|
|
57
|
-
"babel-jest": "^
|
|
57
|
+
"babel-jest": "^26.0.1",
|
|
58
58
|
"cross-env": "^7.0.2",
|
|
59
59
|
"del": "^5.1.0",
|
|
60
60
|
"del-cli": "^3.0.0",
|
|
@@ -64,12 +64,12 @@
|
|
|
64
64
|
"eslint-plugin-prettier": "^3.1.3",
|
|
65
65
|
"husky": "^4.2.5",
|
|
66
66
|
"inspect-loader": "^1.0.0",
|
|
67
|
-
"jest": "^
|
|
68
|
-
"lint-staged": "^10.
|
|
67
|
+
"jest": "^26.0.1",
|
|
68
|
+
"lint-staged": "^10.2.2",
|
|
69
69
|
"memfs": "^3.1.2",
|
|
70
70
|
"npm-run-all": "^4.1.5",
|
|
71
71
|
"prettier": "^2.0.5",
|
|
72
|
-
"standard-version": "^
|
|
72
|
+
"standard-version": "^8.0.0",
|
|
73
73
|
"strip-ansi": "^6.0.0",
|
|
74
74
|
"webpack": "^4.43.0"
|
|
75
75
|
},
|