Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

less-loader

Package Overview
Dependencies
Maintainers
8
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

less-loader - npm Package Compare versions

Comparing version 6.2.0 to 7.0.0

14

CHANGELOG.md

@@ -5,2 +5,16 @@ # Changelog

## [7.0.0](https://github.com/webpack-contrib/less-loader/compare/v6.2.0...v7.0.0) (2020-08-25)
### ⚠ BREAKING CHANGES
* move `less` to `peerDependencies`, the `implementation` option was removed
* `prependData` and `appendData` option were removed in favor the `additionaldata` option
### Features
* added `webpackImporter` option ([#377](https://github.com/webpack-contrib/less-loader/issues/377)) ([12dca5b](https://github.com/webpack-contrib/less-loader/commit/12dca5bb573740472cff8176b7aade184c773ebc))
* added loader context in less plugins ([#378](https://github.com/webpack-contrib/less-loader/issues/378)) ([7b7fc5e](https://github.com/webpack-contrib/less-loader/commit/7b7fc5e841a2c7c587a980648056ed4762014e9d))
* added `additionaldata` option ([#374](https://github.com/webpack-contrib/less-loader/issues/374)) ([2785803](https://github.com/webpack-contrib/less-loader/commit/27858037a2e307fdf437604300f14c8233df4568))
## [6.2.0](https://github.com/webpack-contrib/less-loader/compare/v6.1.3...v6.2.0) (2020-07-03)

@@ -7,0 +21,0 @@

12

dist/index.js

@@ -10,2 +10,4 @@ "use strict";

var _less = _interopRequireDefault(require("less"));
var _loaderUtils = require("loader-utils");

@@ -33,11 +35,7 @@

if (typeof options.prependData !== 'undefined') {
data = typeof options.prependData === 'function' ? `${options.prependData(this)}\n${data}` : `${options.prependData}\n${data}`;
if (typeof options.additionalData !== 'undefined') {
data = typeof options.additionalData === 'function' ? `${options.additionalData(data, this)}` : `${options.additionalData}\n${data}`;
}
if (typeof options.appendData !== 'undefined') {
data = typeof options.appendData === 'function' ? `${data}\n${options.appendData(this)}` : `${data}\n${options.appendData}`;
}
(0, _utils.getLessImplementation)(options.implementation).render(data, lessOptions).then(({
_less.default.render(data, lessOptions).then(({
css,

@@ -44,0 +42,0 @@ map,

@@ -16,4 +16,4 @@ {

},
"prependData": {
"description": "Prepends `Less` code before the actual entry file (https://github.com/webpack-contrib/less-loader#prependdata).",
"additionalData": {
"description": "Prepends/Appends `Less` code to the actual entry file (https://github.com/webpack-contrib/less-loader#additionalData).",
"anyOf": [

@@ -28,13 +28,2 @@ {

},
"appendData": {
"description": "Add `Less` code after the actual entry file (https://github.com/webpack-contrib/less-loader#postponeddata).",
"anyOf": [
{
"type": "string"
},
{
"instanceof": "Function"
}
]
},
"sourceMap": {

@@ -44,5 +33,5 @@ "description": "Enables/Disables generation of source maps (https://github.com/webpack-contrib/less-loader#sourcemap).",

},
"implementation": {
"description": "The implementation of the `Less` to be used (https://github.com/webpack-contrib/less-loader#implementation).",
"type": "object"
"webpackImporter": {
"description": "Enables/Disables default `webpack` importer (https://github.com/webpack-contrib/less-loader#webpackimporter).",
"type": "boolean"
}

@@ -49,0 +38,0 @@ },

@@ -6,3 +6,2 @@ "use strict";

});
exports.getLessImplementation = getLessImplementation;
exports.getLessOptions = getLessOptions;

@@ -15,3 +14,3 @@ exports.isUnsupportedUrl = isUnsupportedUrl;

var _clone = _interopRequireDefault(require("clone"));
var _full = require("klona/full");

@@ -144,3 +143,3 @@ var _loaderUtils = require("loader-utils");

function getLessOptions(loaderContext, loaderOptions) {
const options = (0, _clone.default)(loaderOptions.lessOptions ? typeof loaderOptions.lessOptions === 'function' ? loaderOptions.lessOptions(loaderContext) || {} : loaderOptions.lessOptions : {});
const options = (0, _full.klona)(typeof loaderOptions.lessOptions === 'function' ? loaderOptions.lessOptions(loaderContext) || {} : loaderOptions.lessOptions || {});
const lessOptions = {

@@ -153,3 +152,15 @@ plugins: [],

};
lessOptions.plugins.unshift(createWebpackLessPlugin(loaderContext));
const shouldUseWebpackImporter = typeof loaderOptions.webpackImporter === 'boolean' ? loaderOptions.webpackImporter : true;
if (shouldUseWebpackImporter) {
lessOptions.plugins.unshift(createWebpackLessPlugin(loaderContext));
}
lessOptions.plugins.unshift({
install(lessProcessor) {
// eslint-disable-next-line no-param-reassign
lessProcessor.webpackLoaderContext = loaderContext;
}
});
const useSourceMap = typeof loaderOptions.sourceMap === 'boolean' ? loaderOptions.sourceMap : loaderContext.sourceMap;

@@ -166,10 +177,2 @@

function getLessImplementation(implementation) {
if (typeof implementation !== 'undefined') {
return implementation;
}
return _less.default;
}
function isUnsupportedUrl(url) {

@@ -176,0 +179,0 @@ // Is Windows paths `c:\`

{
"name": "less-loader",
"version": "6.2.0",
"version": "7.0.0",
"description": "A Less loader for webpack. Compiles Less to CSS.",

@@ -41,7 +41,7 @@ "license": "MIT",

"peerDependencies": {
"less": "^3.5.0",
"webpack": "^4.0.0 || ^5.0.0"
},
"dependencies": {
"clone": "^2.1.2",
"less": "^3.11.3",
"klona": "^2.0.3",
"loader-utils": "^2.0.0",

@@ -54,4 +54,4 @@ "schema-utils": "^2.7.0"

"@babel/preset-env": "^7.10.4",
"@commitlint/cli": "^9.0.1",
"@commitlint/config-conventional": "^9.0.1",
"@commitlint/cli": "^10.0.0",
"@commitlint/config-conventional": "^10.0.0",
"@webpack-contrib/defaults": "^6.3.0",

@@ -70,9 +70,10 @@ "@webpack-contrib/eslint-config-webpack": "^3.0.0",

"jest": "^26.1.0",
"less": "^3.12.2",
"lint-staged": "^10.2.11",
"memfs": "^3.2.0",
"npm-run-all": "^4.1.5",
"prettier": "^2.0.5",
"standard-version": "^8.0.0",
"prettier": "^2.1.0",
"standard-version": "^9.0.0",
"strip-ansi": "^6.0.0",
"webpack": "^4.43.0"
"webpack": "^4.44.1"
},

@@ -79,0 +80,0 @@ "keywords": [

@@ -21,6 +21,6 @@ <div align="center">

To begin, you'll need to install `less-loader`:
To begin, you'll need to install `less` and `less-loader`:
```console
$ npm install less-loader --save-dev
$ npm install less less-loader --save-dev
```

@@ -49,9 +49,8 @@

| 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. |
| Name | Type | Default | Description |
| :---------------------------------------: | :------------------: | :----------------------: | :----------------------------------------------------- |
| **[`lessOptions`](#lessoptions)** | `{Object\|Function}` | `{ relativeUrls: true }` | Options for Less. |
| **[`additionalData`](#additionalData)** | `{String\|Function}` | `undefined` | Prepends/Appends `Less` code to the actual entry file. |
| **[`sourceMap`](#sourcemap)** | `{Boolean}` | `compiler.devtool` | Enables/Disables generation of source maps. |
| **[`webpackImporter`](#webpackimporter)** | `{Boolean}` | `true` | Enables/Disables the default Webpack importer. |

@@ -139,3 +138,3 @@ ### `lessOptions`

### `prependData`
### `additionalData`

@@ -146,2 +145,3 @@ Type: `String|Function`

Prepends `Less` code before the actual entry file.
In this case, the `less-loader` will not override the source but just **prepend** the entry's content.

@@ -166,3 +166,3 @@ This is especially useful when some of your Less variables depend on the environment:

options: {
prependData: `@env: ${process.env.NODE_ENV};`,
additionalData: `@env: ${process.env.NODE_ENV};`,
},

@@ -191,3 +191,3 @@ },

options: {
prependData: (loaderContext) => {
additionalData: (content, loaderContext) => {
// More information about available properties https://webpack.js.org/api/loaders/

@@ -198,6 +198,6 @@ const { resourcePath, rootContext } = loaderContext;

if (relativePath === 'styles/foo.less') {
return '@value: 100px;';
return '@value: 100px;' + content;
}
return '@value: 200px;';
return '@value: 200px;' + content;
},

@@ -213,13 +213,2 @@ },

### `appendData`
Type: `String|Function`
Default: `undefined`
AppendData `Less` code after the actual entry file.
This can be useful when you need to rewrite some of your Less variables.:
> ℹ 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.
#### `String`

@@ -319,14 +308,12 @@

### `implementation`
### `webpackImporter`
Type: `Object`
Default: `less`
Type: `Boolean`
Default: `true`
> ⚠ less-loader compatible with Less version 3 only
Enables/Disables the default Webpack importer.
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.
This can improve performance in some cases. Use it with caution because aliases and `@import` at-rules starting with `~` will not work.
For example, to use custom Less implementation, you'd pass:
**webpack.config.js**

@@ -338,3 +325,3 @@ ```js

{
test: /\.less$/,
test: /\.less$/i,
use: [

@@ -346,3 +333,3 @@ 'style-loader',

options: {
implementation: require('less'),
webpackImporter: false,
},

@@ -503,4 +490,3 @@ },

In order to use [plugins](http://lesscss.org/usage/#plugins), simply set the
`plugins` option like this:
In order to use [plugins](http://lesscss.org/usage/#plugins), simply set the `plugins` option like this:

@@ -527,2 +513,16 @@ ```js

> ℹ️ Access to the [loader context](https://webpack.js.org/api/loaders/#the-loader-context) inside the custom plugin can be done using the `less.webpackLoaderContext` property.
```js
module.exports = {
install: function (less, pluginManager, functions) {
functions.add('pi', function () {
// Loader context is available in `less.webpackLoaderContext`
return Math.PI;
});
},
};
```
### Extracting style sheets

@@ -529,0 +529,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc