less-loader
Advanced tools
Comparing version 6.0.0 to 6.1.0
@@ -5,2 +5,14 @@ # Changelog | ||
## [6.1.0](https://github.com/webpack-contrib/less-loader/compare/v6.0.0...v6.1.0) (2020-05-07) | ||
### Features | ||
* new `implementation` option ([#354](https://github.com/webpack-contrib/less-loader/issues/354)) ([d2de80f](https://github.com/webpack-contrib/less-loader/commit/d2de80f9fe6ee11e784260dbda960853ebd2449b)) | ||
### Bug Fixes | ||
* 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)) | ||
## [6.0.0](https://github.com/webpack-contrib/less-loader/compare/v5.0.0...v6.0.0) (2020-04-24) | ||
@@ -7,0 +19,0 @@ |
@@ -8,4 +8,2 @@ "use strict"; | ||
var _less = _interopRequireDefault(require("less")); | ||
var _loaderUtils = require("loader-utils"); | ||
@@ -41,3 +39,3 @@ | ||
_less.default.render(data, lessOptions).then(({ | ||
(0, _utils.getLessImplementation)(options.implementation).render(data, lessOptions).then(({ | ||
css, | ||
@@ -47,5 +45,3 @@ map, | ||
}) => { | ||
imports.forEach(this.addDependency, this); // Removing the sourceMappingURL comment. | ||
// See removeSourceMappingUrl.js for the reasoning behind this. | ||
imports.forEach(this.addDependency, this); | ||
callback(null, css, typeof map === 'string' ? JSON.parse(map) : map); | ||
@@ -52,0 +48,0 @@ }).catch(lessError => { |
@@ -5,3 +5,3 @@ { | ||
"lessOptions": { | ||
"description": "Options to pass through to `less`. (https://github.com/webpack-contrib/less-loader#lessoptions).", | ||
"description": "Options to pass through to `Less` (https://github.com/webpack-contrib/less-loader#lessoptions).", | ||
"anyOf": [ | ||
@@ -42,2 +42,6 @@ { | ||
"type": "boolean" | ||
}, | ||
"implementation": { | ||
"description": "The implementation of the `Less` to be used (https://github.com/webpack-contrib/less-loader#implementation).", | ||
"type": "object" | ||
} | ||
@@ -44,0 +48,0 @@ }, |
@@ -6,8 +6,9 @@ "use strict"; | ||
}); | ||
exports.getLessImplementation = getLessImplementation; | ||
exports.getLessOptions = getLessOptions; | ||
var _less = _interopRequireDefault(require("less")); | ||
var _clone = _interopRequireDefault(require("clone")); | ||
var _less = _interopRequireDefault(require("less")); | ||
var _loaderUtils = require("loader-utils"); | ||
@@ -148,3 +149,3 @@ | ||
}; | ||
lessOptions.plugins.push(createWebpackLessPlugin(loaderContext)); | ||
lessOptions.plugins.unshift(createWebpackLessPlugin(loaderContext)); | ||
const useSourceMap = typeof loaderOptions.sourceMap === 'boolean' ? loaderOptions.sourceMap : loaderContext.sourceMap; | ||
@@ -159,2 +160,10 @@ | ||
return lessOptions; | ||
} // eslint-disable-next-line import/prefer-default-export | ||
} | ||
function getLessImplementation(implementation) { | ||
if (typeof implementation !== 'undefined') { | ||
return implementation; | ||
} | ||
return _less.default; | ||
} |
{ | ||
"name": "less-loader", | ||
"version": "6.0.0", | ||
"version": "6.1.0", | ||
"description": "A Less loader for webpack. Compiles Less to CSS.", | ||
@@ -51,4 +51,4 @@ "license": "MIT", | ||
"@babel/cli": "^7.8.4", | ||
"@babel/core": "^7.9.0", | ||
"@babel/preset-env": "^7.9.5", | ||
"@babel/core": "^7.9.6", | ||
"@babel/preset-env": "^7.9.6", | ||
"@commitlint/cli": "^8.3.5", | ||
@@ -58,3 +58,3 @@ "@commitlint/config-conventional": "^8.3.4", | ||
"@webpack-contrib/eslint-config-webpack": "^3.0.0", | ||
"babel-jest": "^25.4.0", | ||
"babel-jest": "^26.0.1", | ||
"cross-env": "^7.0.2", | ||
@@ -69,8 +69,8 @@ "del": "^5.1.0", | ||
"inspect-loader": "^1.0.0", | ||
"jest": "^25.4.0", | ||
"lint-staged": "^10.1.7", | ||
"jest": "^26.0.1", | ||
"lint-staged": "^10.2.2", | ||
"memfs": "^3.1.2", | ||
"npm-run-all": "^4.1.5", | ||
"prettier": "^2.0.5", | ||
"standard-version": "^7.1.0", | ||
"standard-version": "^8.0.0", | ||
"strip-ansi": "^6.0.0", | ||
@@ -77,0 +77,0 @@ "webpack": "^4.43.0" |
@@ -48,5 +48,14 @@ <div align="center"> | ||
| Name | Type | Default | Description | | ||
| :-------------------------------------: | :------------------: | :----------------------: | :----------------------------------------------- | | ||
| **[`lessOptions`](#lessoptions)** | `{Object\|Function}` | `{ relativeUrls: true }` | Options for Less. | | ||
| **[`prependData`](#prependdata)** | `{String\|Function}` | `undefined` | Prepends Less code before the actual entry file. | | ||
| **[`appendData`](#appenddata)** | `{String\|Function}` | `undefined` | Prepends Less code after the actual entry file. | | ||
| **[`sourceMap`](#sourcemap)** | `{Boolean}` | `compiler.devtool` | Enables/Disables generation of source maps. | | ||
| **[`implementation`](#implementation)** | `{Object}` | `less` | Setup Less implementation to use. | | ||
### `lessOptions` | ||
Type: `Object|Function` | ||
Default: `{ relativeUrls: true }` | ||
@@ -303,2 +312,37 @@ 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: | ||
### `implementation` | ||
Type: `Object` | ||
Default: `less` | ||
> ⚠ less-loader compatible with Less version 3 only | ||
The special `implementation` option determines which implementation of Less to use. | ||
The `implementation` options either accepts `less` as a module. | ||
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. | ||
For example, to use custom Less implementation, you'd pass: | ||
```js | ||
module.exports = { | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.less$/, | ||
use: [ | ||
'style-loader', | ||
'css-loader', | ||
{ | ||
loader: 'less-loader', | ||
options: { | ||
implementation: require('less'), | ||
}, | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
}; | ||
``` | ||
## Examples | ||
@@ -305,0 +349,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
37064
245
552
0