less-loader 4.0.3 → 4.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 CHANGED
@@ -2,6 +2,45 @@
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
+ <a name="4.1.0"></a>
6
+ # [4.1.0](https://github.com/webpack-contrib/less-loader/compare/v4.0.6...v4.1.0) (2018-03-09)
7
+
8
+
9
+ ### Features
10
+
11
+ * **package:** support `less >= v3.0.0` ([#242](https://github.com/webpack-contrib/less-loader/issues/242)) ([d8c9d83](https://github.com/webpack-contrib/less-loader/commit/d8c9d83))
12
+
13
+
14
+
15
+ <a name="4.0.6"></a>
16
+ ## [4.0.6](https://github.com/webpack-contrib/less-loader/compare/v4.0.5...v4.0.6) (2018-02-27)
17
+
18
+
19
+ ### Bug Fixes
20
+
21
+ * **package:** add `webpack >= v4.0.0` (`peerDependencies`) ([#245](https://github.com/webpack-contrib/less-loader/issues/245)) ([011cc73](https://github.com/webpack-contrib/less-loader/commit/011cc73))
22
+
23
+
24
+
25
+ <a name="4.0.5"></a>
26
+ ## [4.0.5](https://github.com/webpack-contrib/less-loader/compare/v4.0.4...v4.0.5) (2017-07-10)
27
+
28
+
29
+ ### Chore
30
+
31
+ * support `webpack@3` ([670ab18](https://github.com/webpack-contrib/less-loader/commit/670ab18))
32
+
33
+
34
+ <a name="4.0.4"></a>
35
+ ## [4.0.4](https://github.com/webpack-contrib/less-loader/compare/v4.0.3...v4.0.4) (2017-05-30)
36
+
37
+
38
+ ### Bug Fixes
39
+
40
+ * resolve `[@import](https://github.com/import)` with absolute paths ([#201](https://github.com/webpack-contrib/less-loader/issues/201)) ([a3f9601](https://github.com/webpack-contrib/less-loader/commit/a3f9601)), closes [webpack-contrib/less-loader#93](https://github.com/webpack-contrib/less-loader/issues/93)
41
+
42
+
43
+
5
44
  <a name="4.0.3"></a>
6
45
  ## [4.0.3](https://github.com/webpack-contrib/less-loader/compare/v4.0.2...v4.0.3) (2017-03-30)
7
46
 
package/README.md CHANGED
@@ -20,7 +20,7 @@
20
20
 
21
21
  <p align="center">Compiles Less to CSS.</p>
22
22
 
23
- Use the [css-loader](https://github.com/webpack-contrib/css-loader) or the [raw-loader](https://github.com/webpack-contrib/raw-loader) to turn it into a JS module and the [ExtractTextPlugin](https://github.com/webpack-contrib/extract-text-webpack-plugin) to extract it into a separate file.
23
+ Use the [`css-loader`](https://github.com/webpack-contrib/css-loader) or the [`raw-loader`](https://github.com/webpack-contrib/raw-loader) to turn it into a JS module and the [ExtractTextPlugin](https://github.com/webpack-contrib/extract-text-webpack-plugin) to extract it into a separate file.
24
24
 
25
25
 
26
26
  <h2 align="center">Install</h2>
@@ -29,11 +29,11 @@ Use the [css-loader](https://github.com/webpack-contrib/css-loader) or the [raw-
29
29
  npm install --save-dev less-loader less
30
30
  ```
31
31
 
32
- The less-loader requires [less](https://github.com/less/less.js) as [`peerDependency`](https://docs.npmjs.com/files/package.json#peerdependencies). Thus you are able to control the versions accurately.
32
+ The `less-loader` requires [less](https://github.com/less/less.js) as [`peerDependency`](https://docs.npmjs.com/files/package.json#peerdependencies). Thus you are able to control the versions accurately.
33
33
 
34
34
  <h2 align="center">Examples</h2>
35
35
 
36
- Chain the less-loader with the [css-loader](https://github.com/webpack-contrib/css-loader) and the [style-loader](https://github.com/webpack-contrib/style-loader) to immediately apply all styles to the DOM.
36
+ Chain the `less-loader` with the [`css-loader`](https://github.com/webpack-contrib/css-loader) and the [`style-loader`](https://github.com/webpack-contrib/style-loader) to immediately apply all styles to the DOM.
37
37
 
38
38
  ```js
39
39
  // webpack.config.js
@@ -54,7 +54,7 @@ module.exports = {
54
54
  };
55
55
  ```
56
56
 
57
- You can pass any Less specific options to the less-loader via [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:
57
+ You can pass any Less specific options to the `less-loader` via [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:
58
58
 
59
59
  ```js
60
60
  // webpack.config.js
@@ -118,11 +118,11 @@ module.exports = {
118
118
 
119
119
  ### Imports
120
120
 
121
- Starting with less-loader 4, you can now choose between Less' builtin resolver and webpack's resolver. By default, webpack's resolver is used.
121
+ Starting with `less-loader` 4, you can now choose between Less' builtin resolver and webpack's resolver. By default, webpack's resolver is used.
122
122
 
123
123
  #### webpack resolver
124
124
 
125
- webpack provides an [advanced mechanism to resolve files](https://webpack.js.org/configuration/resolve/). The less-loader applies a Less plugin that passes all queries to the webpack resolver. Thus you can import your Less modules from `node_modules`. Just prepend them with a `~` which tells webpack to look up the [`modules`](https://webpack.js.org/configuration/resolve/#resolve-modules).
125
+ webpack provides an [advanced mechanism to resolve files](https://webpack.js.org/configuration/resolve/). The `less-loader` applies a Less plugin that passes all queries to the webpack resolver. Thus you can import your Less modules from `node_modules`. Just prepend them with a `~` which tells webpack to look up the [`modules`](https://webpack.js.org/configuration/resolve/#resolve-modules).
126
126
 
127
127
  ```css
128
128
  @import "~bootstrap/less/bootstrap";
@@ -152,7 +152,7 @@ module.exports = {
152
152
 
153
153
  #### Less resolver
154
154
 
155
- If you specify the `paths` option, the less-loader will not use webpack's resolver. Modules, that can't be resolved in the local folder, will be searched in the given `paths`. This is Less' default behavior. `paths` should be an array with absolute paths:
155
+ If you specify the `paths` option, the `less-loader` will not use webpack's resolver. Modules, that can't be resolved in the local folder, will be searched in the given `paths`. This is Less' default behavior. `paths` should be an array with absolute paths:
156
156
 
157
157
  ```js
158
158
  // webpack.config.js
@@ -206,12 +206,12 @@ Bundling CSS with webpack has some nice advantages like referencing images and f
206
206
 
207
207
  There are two possibilities to extract a style sheet from the bundle:
208
208
 
209
- - [extract-loader](https://github.com/peerigon/extract-loader) (simpler, but specialized on the css-loader's output)
210
- - [extract-text-webpack-plugin](https://github.com/webpack-contrib/extract-text-webpack-plugin) (more complex, but works in all use-cases)
209
+ - [`extract-loader`](https://github.com/peerigon/extract-loader) (simpler, but specialized on the css-loader's output)
210
+ - [`ExtractTextWebpackPlugin`](https://github.com/webpack-contrib/extract-text-webpack-plugin) (more complex, but works in all use-cases)
211
211
 
212
212
  ### Source maps
213
213
 
214
- To enable CSS source maps, you'll need to pass the `sourceMap` option to the less-loader *and* the css-loader. Your `webpack.config.js` should look like this:
214
+ To enable CSS source maps, you'll need to pass the `sourceMap` option to the `less-loader` *and* the `css-loader`. Your `webpack.config.js` should look like this:
215
215
 
216
216
  ```javascript
217
217
  module.exports = {
@@ -235,7 +235,7 @@ module.exports = {
235
235
  };
236
236
  ```
237
237
 
238
- Also checkout the [sourceMaps example](/examples/sourceMaps).
238
+ Also checkout the [sourceMaps example](https://github.com/webpack-contrib/less-loader/tree/master/examples/sourceMaps).
239
239
 
240
240
  If you want to edit the original Less files inside Chrome, [there's a good blog post](https://medium.com/@toolmantim/getting-started-with-css-sourcemaps-and-in-browser-sass-editing-b4daab987fb0). The blog post is about Sass but it also works for Less.
241
241
 
package/dist/cjs.js ADDED
@@ -0,0 +1,3 @@
1
+ 'use strict';
2
+
3
+ module.exports = require('./index').default;
@@ -1,3 +1,5 @@
1
+ 'use strict';
2
+
1
3
  var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
2
4
 
3
5
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
@@ -6,6 +8,7 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen
6
8
 
7
9
  function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
8
10
 
11
+ /* eslint-disable class-methods-use-this */
9
12
  var less = require('less');
10
13
  var loaderUtils = require('loader-utils');
11
14
  var pify = require('pify');
@@ -13,6 +16,7 @@ var pify = require('pify');
13
16
  var stringifyLoader = require.resolve('./stringifyLoader.js');
14
17
  var trailingSlash = /[/\\]$/;
15
18
  var isLessCompatible = /\.(le|c)ss$/;
19
+
16
20
  // Less automatically adds a .less file extension if no extension was given.
17
21
  // This is problematic if there is a module request like @import "~some-module";
18
22
  // because in this case Less will call our file manager with `~some-module.less`.
@@ -21,6 +25,11 @@ var isLessCompatible = /\.(le|c)ss$/;
21
25
  // However, we must not match something like @import "~some-module/file.less";
22
26
  var matchMalformedModuleFilename = /(~[^/\\]+)\.less$/;
23
27
 
28
+ // This somewhat changed in Less 3.x. Now the file name comes without the
29
+ // automatically added extension whereas the extension is passed in as `options.ext`.
30
+ // So, if the file name matches this regexp, we simply ignore the proposed extension.
31
+ var isModuleName = /^~[^/\\]+$/;
32
+
24
33
  /**
25
34
  * Creates a Less plugin that uses webpack's resolving engine that is provided by the loaderContext.
26
35
  *
@@ -46,17 +55,36 @@ function createWebpackLessPlugin(loaderContext) {
46
55
 
47
56
  _createClass(WebpackFileManager, [{
48
57
  key: 'supports',
49
- value: function supports() /* filename, currentDirectory, options, environment */{
50
- // eslint-disable-line class-methods-use-this
58
+ value: function supports() {
51
59
  // Our WebpackFileManager handles all the files
52
60
  return true;
53
61
  }
62
+
63
+ // Sync resolving is used at least by the `data-uri` function.
64
+ // This file manager doesn't know how to do it, so let's delegate it
65
+ // to the default file manager of Less.
66
+ // We could probably use loaderContext.resolveSync, but it's deprecated,
67
+ // see https://webpack.js.org/api/loaders/#this-resolvesync
68
+
69
+ }, {
70
+ key: 'supportsSync',
71
+ value: function supportsSync() {
72
+ return false;
73
+ }
54
74
  }, {
55
75
  key: 'loadFile',
56
- value: function loadFile(filename, currentDirectory /* , options, environment */) {
57
- // eslint-disable-line class-methods-use-this
58
- var url = filename.replace(matchMalformedModuleFilename, '$1');
59
- var moduleRequest = loaderUtils.urlToRequest(url);
76
+ value: function loadFile(filename, currentDirectory, options) {
77
+ var url = void 0;
78
+ if (less.version[0] >= 3) {
79
+ if (options.ext && !isModuleName.test(filename)) {
80
+ url = this.tryAppendExtension(filename, options.ext);
81
+ } else {
82
+ url = filename;
83
+ }
84
+ } else {
85
+ url = filename.replace(matchMalformedModuleFilename, '$1');
86
+ }
87
+ var moduleRequest = loaderUtils.urlToRequest(url, url.charAt(0) === '/' ? '' : null);
60
88
  // Less is giving us trailing slashes, but the context should have no trailing slash
61
89
  var context = currentDirectory.replace(trailingSlash, '');
62
90
  var resolvedFilename = void 0;
@@ -92,5 +120,4 @@ function createWebpackLessPlugin(loaderContext) {
92
120
  };
93
121
  }
94
122
 
95
- module.exports = createWebpackLessPlugin;
96
- //# sourceMappingURL=createWebpackLessPlugin.js.map
123
+ module.exports = createWebpackLessPlugin;
@@ -1,3 +1,5 @@
1
+ 'use strict';
2
+
1
3
  function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
2
4
 
3
5
  var os = require('os');
@@ -57,5 +59,4 @@ function formatLessError(err) {
57
59
  return err;
58
60
  } /* eslint-enable no-param-reassign */
59
61
 
60
- module.exports = formatLessError;
61
- //# sourceMappingURL=formatLessError.js.map
62
+ module.exports = formatLessError;
@@ -1,3 +1,5 @@
1
+ 'use strict';
2
+
1
3
  var loaderUtils = require('loader-utils');
2
4
  var clone = require('clone');
3
5
  var createWebpackLessPlugin = require('./createWebpackLessPlugin');
@@ -36,5 +38,4 @@ function getOptions(loaderContext) {
36
38
  return options;
37
39
  }
38
40
 
39
- module.exports = getOptions;
40
- //# sourceMappingURL=getOptions.js.map
41
+ module.exports = getOptions;
package/dist/index.js CHANGED
@@ -1,13 +1,32 @@
1
- var less = require('less');
2
- var pify = require('pify');
3
- var processResult = require('./processResult');
4
- var getOptions = require('./getOptions');
1
+ 'use strict';
5
2
 
6
- var render = pify(less.render.bind(less));
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ var _less = require('less');
8
+
9
+ var _less2 = _interopRequireDefault(_less);
10
+
11
+ var _pify = require('pify');
12
+
13
+ var _pify2 = _interopRequireDefault(_pify);
14
+
15
+ var _processResult = require('./processResult');
16
+
17
+ var _processResult2 = _interopRequireDefault(_processResult);
18
+
19
+ var _getOptions = require('./getOptions');
20
+
21
+ var _getOptions2 = _interopRequireDefault(_getOptions);
22
+
23
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24
+
25
+ var render = (0, _pify2.default)(_less2.default.render.bind(_less2.default));
7
26
 
8
27
  function lessLoader(source) {
9
28
  var loaderContext = this;
10
- var options = getOptions(loaderContext);
29
+ var options = (0, _getOptions2.default)(loaderContext);
11
30
  var done = loaderContext.async();
12
31
  var isSync = typeof done !== 'function';
13
32
 
@@ -15,8 +34,7 @@ function lessLoader(source) {
15
34
  throw new Error('Synchronous compilation is not supported anymore. See https://github.com/webpack-contrib/less-loader/issues/84');
16
35
  }
17
36
 
18
- processResult(loaderContext, render(source, options));
37
+ (0, _processResult2.default)(loaderContext, render(source, options));
19
38
  }
20
39
 
21
- module.exports = lessLoader;
22
- //# sourceMappingURL=index.js.map
40
+ exports.default = lessLoader;
@@ -1,3 +1,5 @@
1
+ 'use strict';
2
+
1
3
  var removeSourceMappingUrl = require('./removeSourceMappingUrl');
2
4
  var formatLessError = require('./formatLessError');
3
5
 
@@ -33,5 +35,4 @@ function processResult(loaderContext, resultPromise) {
33
35
  }, callback);
34
36
  }
35
37
 
36
- module.exports = processResult;
37
- //# sourceMappingURL=processResult.js.map
38
+ module.exports = processResult;
@@ -1,3 +1,5 @@
1
+ 'use strict';
2
+
1
3
  var matchSourceMappingUrl = /\/\*# sourceMappingURL=[^*]+\*\//;
2
4
 
3
5
  /**
@@ -14,5 +16,4 @@ function removeSourceMappingUrl(content) {
14
16
  return content.replace(matchSourceMappingUrl, '');
15
17
  }
16
18
 
17
- module.exports = removeSourceMappingUrl;
18
- //# sourceMappingURL=removeSourceMappingUrl.js.map
19
+ module.exports = removeSourceMappingUrl;
@@ -1,3 +1,5 @@
1
+ "use strict";
2
+
1
3
  /**
2
4
  * The stringifyLoader turns any content into a valid JavaScript string. This allows us to load any content
3
5
  * with loaderContext.loadModule() without webpack complaining about non-JS modules.
@@ -9,5 +11,4 @@ function stringifyLoader(content) {
9
11
  return JSON.stringify(content);
10
12
  }
11
13
 
12
- module.exports = stringifyLoader;
13
- //# sourceMappingURL=stringifyLoader.js.map
14
+ module.exports = stringifyLoader;
package/package.json CHANGED
@@ -1,76 +1,71 @@
1
1
  {
2
2
  "name": "less-loader",
3
- "version": "4.0.3",
3
+ "version": "4.1.0",
4
4
  "author": "Johannes Ewald @jhnns",
5
5
  "description": "Less loader for webpack. Compiles Less to CSS.",
6
- "main": "dist/index.js",
6
+ "license": "MIT",
7
+ "engines": {
8
+ "node": ">= 4.8 < 5.0.0 || >= 5.10"
9
+ },
10
+ "main": "dist/cjs.js",
11
+ "files": [
12
+ "dist"
13
+ ],
7
14
  "scripts": {
15
+ "start": "npm run build -- -w",
16
+ "build": "cross-env NODE_ENV=production babel src -d dist --ignore 'src/**/*.test.js' --copy-files",
17
+ "clean": "del-cli dist",
8
18
  "create-spec": "babel-node test/helpers/createSpec.js",
19
+ "lint": "eslint --cache src test",
9
20
  "pretest": "npm run create-spec",
10
21
  "test": "jest",
11
22
  "posttest": "npm run lint",
12
- "travis:test": "yarn run test",
13
- "appveyor:test": "npm test",
14
- "lint": "eslint --cache src test",
15
- "webpack-defaults": "webpack-defaults",
16
- "start": "yarn run serve:dev src",
17
- "build": "cross-env NODE_ENV=production babel -s true src -d dist --ignore 'src/**/*.test.js'",
18
- "clean:dist": "del-cli dist",
19
23
  "lint-staged": "lint-staged",
20
- "prebuild": "yarn run clean:dist",
21
- "prepublish": "yarn run build",
22
- "release": "yarn run standard-version",
24
+ "prebuild": "npm run clean",
25
+ "prepare": "npm run build",
26
+ "release": "standard-version",
23
27
  "security": "nsp check",
24
- "serve:dev": "nodemon $2 --exec babel-node",
25
- "test:watch": "jest --watch",
26
28
  "test:coverage": "jest --collectCoverageFrom='src/**/*.js' --coverage",
27
- "travis:coverage": "yarn run test:coverage",
28
- "travis:lint": "yarn run lint && yarn run security"
29
- },
30
- "engines": {
31
- "node": ">=4.3 <5.0.0 || >=5.10"
29
+ "travis:lint": "npm run lint && npm run security",
30
+ "travis:test": "npm run test -- --runInBand",
31
+ "pretravis:coverage": "npm run pretest",
32
+ "travis:coverage": "npm run test:coverage -- --runInBand",
33
+ "appveyor:test": "npm run test",
34
+ "defaults": "webpack-defaults"
32
35
  },
33
36
  "dependencies": {
34
37
  "clone": "^2.1.1",
35
38
  "loader-utils": "^1.1.0",
36
- "pify": "^2.3.0"
39
+ "pify": "^3.0.0"
37
40
  },
38
41
  "peerDependencies": {
39
- "less": "^2.3.1",
40
- "webpack": "^2.2.0"
42
+ "less": "^2.3.1 || ^3.0.0",
43
+ "webpack": "^2.0.0 || ^3.0.0 || ^4.0.0"
41
44
  },
42
45
  "devDependencies": {
43
46
  "babel-cli": "^6.24.0",
44
- "babel-jest": "^19.0.0",
47
+ "babel-jest": "^21.2.0",
45
48
  "babel-plugin-transform-object-rest-spread": "^6.23.0",
46
49
  "babel-polyfill": "^6.23.0",
47
- "babel-preset-env": "^1.2.2",
50
+ "babel-preset-env": "^1.6.0",
48
51
  "cross-env": "^3.2.4",
49
52
  "del-cli": "^0.2.1",
50
53
  "eslint": "^3.18.0",
51
54
  "eslint-config-webpack": "^1.2.1",
52
55
  "eslint-plugin-import": "^2.2.0",
53
56
  "inspect-loader": "^1.0.0",
54
- "jest": "^19.0.2",
55
- "less": "^2.3.1",
57
+ "jest": "^21.2.1",
58
+ "less": "^3.0.1",
56
59
  "lint-staged": "^3.4.0",
57
- "nodemon": "^1.11.0",
58
60
  "nsp": "^2.6.3",
59
61
  "pre-commit": "^1.2.2",
60
62
  "standard-version": "^4.0.0",
61
- "webpack": "^2.3.2",
62
- "webpack-defaults": "^0.4.5"
63
+ "webpack": "^3.0.0",
64
+ "webpack-defaults": "^1.6.0"
63
65
  },
64
- "repository": {
65
- "type": "git",
66
- "url": "git://github.com/webpack-contrib/less-loader.git"
67
- },
68
- "license": "MIT",
69
- "files": [
70
- "README.md",
71
- "LICENSE",
72
- "dist"
73
- ],
66
+ "repository": "https://github.com/webpack-contrib/less-loader.git",
67
+ "bugs": "https://github.com/webpack-contrib/less-loader/issues",
68
+ "homepage": "https://github.com/webpack-contrib/less-loader",
74
69
  "pre-commit": "lint-staged",
75
70
  "lint-staged": {
76
71
  "*.js": [
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/createWebpackLessPlugin.js"],"names":["less","require","loaderUtils","pify","stringifyLoader","resolve","trailingSlash","isLessCompatible","matchMalformedModuleFilename","createWebpackLessPlugin","loaderContext","fs","bind","loadModule","readFile","WebpackFileManager","filename","currentDirectory","url","replace","moduleRequest","urlToRequest","context","resolvedFilename","then","f","addDependency","test","contents","toString","join","JSON","parse","FileManager","install","lessInstance","pluginManager","addFileManager","minVersion","module","exports"],"mappings":";;;;;;;;AAAA,IAAMA,OAAOC,QAAQ,MAAR,CAAb;AACA,IAAMC,cAAcD,QAAQ,cAAR,CAApB;AACA,IAAME,OAAOF,QAAQ,MAAR,CAAb;;AAEA,IAAMG,kBAAkBH,QAAQI,OAAR,CAAgB,sBAAhB,CAAxB;AACA,IAAMC,gBAAgB,QAAtB;AACA,IAAMC,mBAAmB,aAAzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAMC,+BAA+B,mBAArC;;AAEA;;;;;;;AAOA,SAASC,uBAAT,CAAiCC,aAAjC,EAAgD;AAAA,MACtCC,EADsC,GAC/BD,aAD+B,CACtCC,EADsC;;AAE9C,MAAMN,UAAUF,KAAKO,cAAcL,OAAd,CAAsBO,IAAtB,CAA2BF,aAA3B,CAAL,CAAhB;AACA,MAAMG,aAAaV,KAAKO,cAAcG,UAAd,CAAyBD,IAAzB,CAA8BF,aAA9B,CAAL,CAAnB;AACA,MAAMI,WAAWX,KAAKQ,GAAGG,QAAH,CAAYF,IAAZ,CAAiBD,EAAjB,CAAL,CAAjB;;AAJ8C,MAMxCI,kBANwC;AAAA;;AAAA;AAAA;;AAAA;AAAA;;AAAA;AAAA;AAAA,iCAOnC,sDAAwD;AAAE;AACjE;AACA,eAAO,IAAP;AACD;AAV2C;AAAA;AAAA,+BAYnCC,QAZmC,EAYzBC,gBAZyB,CAYR,4BAZQ,EAYsB;AAAE;AAClE,YAAMC,MAAMF,SAASG,OAAT,CAAiBX,4BAAjB,EAA+C,IAA/C,CAAZ;AACA,YAAMY,gBAAgBlB,YAAYmB,YAAZ,CAAyBH,GAAzB,CAAtB;AACA;AACA,YAAMI,UAAUL,iBAAiBE,OAAjB,CAAyBb,aAAzB,EAAwC,EAAxC,CAAhB;AACA,YAAIiB,yBAAJ;;AAEA,eAAOlB,QAAQiB,OAAR,EAAiBF,aAAjB,EACJI,IADI,CACC,UAACC,CAAD,EAAO;AACXF,6BAAmBE,CAAnB;AACAf,wBAAcgB,aAAd,CAA4BH,gBAA5B;;AAEA,cAAIhB,iBAAiBoB,IAAjB,CAAsBJ,gBAAtB,CAAJ,EAA6C;AAC3C,mBAAOT,SAASS,gBAAT,EACJC,IADI,CACC;AAAA,qBAAYI,SAASC,QAAT,CAAkB,MAAlB,CAAZ;AAAA,aADD,CAAP;AAED;;AAED,iBAAOhB,WAAW,CAACT,eAAD,EAAkBmB,gBAAlB,EAAoCO,IAApC,CAAyC,GAAzC,CAAX,EACJN,IADI,CACCO,KAAKC,KADN,CAAP;AAED,SAZI,EAaJR,IAbI,CAaC,UAACI,QAAD,EAAc;AAClB,iBAAO;AACLA,oBADK;AAELZ,sBAAUO;AAFL,WAAP;AAID,SAlBI,CAAP;AAmBD;AAtC2C;;AAAA;AAAA,IAMbvB,KAAKiC,WANQ;;AAyC9C,SAAO;AACLC,YAAQC,YAAR,EAAsBC,aAAtB,EAAqC;AACnCA,oBAAcC,cAAd,CAA6B,IAAItB,kBAAJ,EAA7B;AACD,KAHI;AAILuB,gBAAY,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP;AAJP,GAAP;AAMD;;AAEDC,OAAOC,OAAP,GAAiB/B,uBAAjB","file":"createWebpackLessPlugin.js","sourcesContent":["const less = require('less');\nconst loaderUtils = require('loader-utils');\nconst pify = require('pify');\n\nconst stringifyLoader = require.resolve('./stringifyLoader.js');\nconst trailingSlash = /[/\\\\]$/;\nconst isLessCompatible = /\\.(le|c)ss$/;\n// Less automatically adds a .less file extension if no extension was given.\n// This is problematic if there is a module request like @import \"~some-module\";\n// because in this case Less will call our file manager with `~some-module.less`.\n// Since dots in module names are highly discouraged, we can safely assume that\n// this is an error and we need to remove the .less extension again.\n// However, we must not match something like @import \"~some-module/file.less\";\nconst matchMalformedModuleFilename = /(~[^/\\\\]+)\\.less$/;\n\n/**\n * Creates a Less plugin that uses webpack's resolving engine that is provided by the loaderContext.\n *\n * @param {LoaderContext} loaderContext\n * @param {string=} root\n * @returns {LessPlugin}\n */\nfunction createWebpackLessPlugin(loaderContext) {\n const { fs } = loaderContext;\n const resolve = pify(loaderContext.resolve.bind(loaderContext));\n const loadModule = pify(loaderContext.loadModule.bind(loaderContext));\n const readFile = pify(fs.readFile.bind(fs));\n\n class WebpackFileManager extends less.FileManager {\n supports(/* filename, currentDirectory, options, environment */) { // eslint-disable-line class-methods-use-this\n // Our WebpackFileManager handles all the files\n return true;\n }\n\n loadFile(filename, currentDirectory /* , options, environment */) { // eslint-disable-line class-methods-use-this\n const url = filename.replace(matchMalformedModuleFilename, '$1');\n const moduleRequest = loaderUtils.urlToRequest(url);\n // Less is giving us trailing slashes, but the context should have no trailing slash\n const context = currentDirectory.replace(trailingSlash, '');\n let resolvedFilename;\n\n return resolve(context, moduleRequest)\n .then((f) => {\n resolvedFilename = f;\n loaderContext.addDependency(resolvedFilename);\n\n if (isLessCompatible.test(resolvedFilename)) {\n return readFile(resolvedFilename)\n .then(contents => contents.toString('utf8'));\n }\n\n return loadModule([stringifyLoader, resolvedFilename].join('!'))\n .then(JSON.parse);\n })\n .then((contents) => {\n return {\n contents,\n filename: resolvedFilename,\n };\n });\n }\n }\n\n return {\n install(lessInstance, pluginManager) {\n pluginManager.addFileManager(new WebpackFileManager());\n },\n minVersion: [2, 1, 1],\n };\n}\n\nmodule.exports = createWebpackLessPlugin;\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/formatLessError.js"],"names":["os","require","getFileExcerptIfPossible","lessErr","excerpt","extract","slice","column","Math","max","shift","push","Array","join","unexpectedErr","formatLessError","err","msg","message","hideStack","EOL","charAt","toUpperCase","filename","line","module","exports"],"mappings":";;AAAA,IAAMA,KAAKC,QAAQ,IAAR,CAAX;;AAEA;;;;;;;;;AASA,SAASC,wBAAT,CAAkCC,OAAlC,EAA2C;AACzC,MAAI;AACF,QAAMC,UAAUD,QAAQE,OAAR,CAAgBC,KAAhB,CAAsB,CAAtB,EAAyB,CAAzB,CAAhB;AACA,QAAMC,SAASC,KAAKC,GAAL,CAASN,QAAQI,MAAR,GAAiB,CAA1B,EAA6B,CAA7B,CAAf;;AAEA,QAAI,OAAOH,QAAQ,CAAR,CAAP,KAAsB,WAA1B,EAAuC;AACrCA,cAAQM,KAAR;AACD;;AAEDN,YAAQO,IAAR,CAAc,GAAE,IAAIC,KAAJ,CAAUL,MAAV,EAAkBM,IAAlB,CAAuB,GAAvB,CAA4B,GAA5C;;AAEA,WAAOT,OAAP;AACD,GAXD,CAWE,OAAOU,aAAP,EAAsB;AACtB;AACA,WAAO,EAAP;AACD;AACF;;AAED;;;;;;;;;;;;;;;AAeA,SAASC,eAAT,CAAyBC,GAAzB,EAA8B;AAAE;AAC9B,MAAMC,MAAMD,IAAIE,OAAhB;;AAEA;AACA;AACAF,MAAIG,SAAJ,GAAgB,IAAhB;;AAEAH,MAAIE,OAAJ,GAAc,CACZlB,GAAGoB,GADS,4BAETlB,yBAAyBc,GAAzB,CAFS,IAGZC,IAAII,MAAJ,CAAW,CAAX,EAAcC,WAAd,KAA8BL,IAAIX,KAAJ,CAAU,CAAV,CAHlB,EAIX,YAAWU,IAAIO,QAAS,UAASP,IAAIQ,IAAK,YAAWR,IAAIT,MAAO,GAJrD,GAKZM,IALY,CAKPb,GAAGoB,GALI,CAAd;;AAOA,SAAOJ,GAAP;AACD,C,CAAC;;AAEFS,OAAOC,OAAP,GAAiBX,eAAjB","file":"formatLessError.js","sourcesContent":["const os = require('os');\n\n/**\n * Tries to get an excerpt of the file where the error happened.\n * Uses err.line and err.column.\n *\n * Returns an empty string if the excerpt could not be retrieved.\n *\n * @param {LessError} err\n * @returns {Array<string>}\n */\nfunction getFileExcerptIfPossible(lessErr) {\n try {\n const excerpt = lessErr.extract.slice(0, 2);\n const column = Math.max(lessErr.column - 1, 0);\n\n if (typeof excerpt[0] === 'undefined') {\n excerpt.shift();\n }\n\n excerpt.push(`${new Array(column).join(' ')}^`);\n\n return excerpt;\n } catch (unexpectedErr) {\n // If anything goes wrong here, we don't want any errors to be reported to the user\n return [];\n }\n}\n\n/**\n * Beautifies the error message from Less.\n *\n * @param {LessError} lessErr\n * @param {string} lessErr.type - e.g. 'Name'\n * @param {string} lessErr.message - e.g. '.undefined-mixin is undefined'\n * @param {string} lessErr.filename - e.g. '/path/to/style.less'\n * @param {number} lessErr.index - e.g. 352\n * @param {number} lessErr.line - e.g. 31\n * @param {number} lessErr.callLine - e.g. NaN\n * @param {string} lessErr.callExtract - e.g. undefined\n * @param {number} lessErr.column - e.g. 6\n * @param {Array<string>} lessErr.extract - e.g. [' .my-style {', ' .undefined-mixin;', ' display: block;']\n * @returns {LessError}\n */\nfunction formatLessError(err) { /* eslint-disable no-param-reassign */\n const msg = err.message;\n\n // Instruct webpack to hide the JS stack from the console\n // Usually you're only interested in the SASS stack in this case.\n err.hideStack = true;\n\n err.message = [\n os.EOL,\n ...getFileExcerptIfPossible(err),\n msg.charAt(0).toUpperCase() + msg.slice(1),\n ` in ${err.filename} (line ${err.line}, column ${err.column})`,\n ].join(os.EOL);\n\n return err;\n} /* eslint-enable no-param-reassign */\n\nmodule.exports = formatLessError;\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/getOptions.js"],"names":["loaderUtils","require","clone","createWebpackLessPlugin","getOptions","loaderContext","options","plugins","relativeUrls","compress","Boolean","minimize","filename","resource","push","sourceMap","outputSourceFiles","module","exports"],"mappings":"AAAA,IAAMA,cAAcC,QAAQ,cAAR,CAApB;AACA,IAAMC,QAAQD,QAAQ,OAAR,CAAd;AACA,IAAME,0BAA0BF,QAAQ,2BAAR,CAAhC;;AAEA;;;;;AAKA,SAASG,UAAT,CAAoBC,aAApB,EAAmC;AACjC,MAAMC;AACJC,aAAS,EADL;AAEJC,kBAAc,IAFV;AAGJC,cAAUC,QAAQL,cAAcM,QAAtB;AAHN,KAIDT,MAAMF,YAAYI,UAAZ,CAAuBC,aAAvB,CAAN,CAJC,CAAN;;AAOA;AACAC,UAAQM,QAAR,GAAmBP,cAAcQ,QAAjC;;AAEA;AACA,MAAI,WAAWP,OAAX,KAAuB,KAA3B,EAAkC;AAChC;AACAA,YAAQC,OAAR,CAAgBO,IAAhB,CAAqBX,wBAAwBE,aAAxB,CAArB;AACD;;AAED,MAAIC,QAAQS,SAAZ,EAAuB;AACrB,QAAI,OAAOT,QAAQS,SAAf,KAA6B,SAAjC,EAA4C;AAC1CT,cAAQS,SAAR,GAAoB,EAApB;AACD;AACD,QAAI,uBAAuBT,QAAQS,SAA/B,KAA6C,KAAjD,EAAwD;AACtD;AACAT,cAAQS,SAAR,CAAkBC,iBAAlB,GAAsC,IAAtC;AACD;AACF;;AAED,SAAOV,OAAP;AACD;;AAEDW,OAAOC,OAAP,GAAiBd,UAAjB","file":"getOptions.js","sourcesContent":["const loaderUtils = require('loader-utils');\nconst clone = require('clone');\nconst createWebpackLessPlugin = require('./createWebpackLessPlugin');\n\n/**\n * Retrieves the options from the loaderContext, makes a deep copy of it and normalizes it for further consumption.\n *\n * @param {LoaderContext} loaderContext\n */\nfunction getOptions(loaderContext) {\n const options = {\n plugins: [],\n relativeUrls: true,\n compress: Boolean(loaderContext.minimize),\n ...clone(loaderUtils.getOptions(loaderContext)),\n };\n\n // We need to set the filename because otherwise our WebpackFileManager will receive an undefined path for the entry\n options.filename = loaderContext.resource;\n\n // When no paths are given, we use the webpack resolver\n if ('paths' in options === false) {\n // It's safe to mutate the array now because it has already been cloned\n options.plugins.push(createWebpackLessPlugin(loaderContext));\n }\n\n if (options.sourceMap) {\n if (typeof options.sourceMap === 'boolean') {\n options.sourceMap = {};\n }\n if ('outputSourceFiles' in options.sourceMap === false) {\n // Include source files as `sourceContents` as sane default since this makes source maps \"just work\" in most cases\n options.sourceMap.outputSourceFiles = true;\n }\n }\n\n return options;\n}\n\nmodule.exports = getOptions;\n"]}
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/index.js"],"names":["less","require","pify","processResult","getOptions","render","bind","lessLoader","source","loaderContext","options","done","async","isSync","Error","module","exports"],"mappings":"AAAA,IAAMA,OAAOC,QAAQ,MAAR,CAAb;AACA,IAAMC,OAAOD,QAAQ,MAAR,CAAb;AACA,IAAME,gBAAgBF,QAAQ,iBAAR,CAAtB;AACA,IAAMG,aAAaH,QAAQ,cAAR,CAAnB;;AAEA,IAAMI,SAASH,KAAKF,KAAKK,MAAL,CAAYC,IAAZ,CAAiBN,IAAjB,CAAL,CAAf;;AAEA,SAASO,UAAT,CAAoBC,MAApB,EAA4B;AAC1B,MAAMC,gBAAgB,IAAtB;AACA,MAAMC,UAAUN,WAAWK,aAAX,CAAhB;AACA,MAAME,OAAOF,cAAcG,KAAd,EAAb;AACA,MAAMC,SAAS,OAAOF,IAAP,KAAgB,UAA/B;;AAEA,MAAIE,MAAJ,EAAY;AACV,UAAM,IAAIC,KAAJ,CAAU,gHAAV,CAAN;AACD;;AAEDX,gBAAcM,aAAd,EAA6BJ,OAAOG,MAAP,EAAeE,OAAf,CAA7B;AACD;;AAEDK,OAAOC,OAAP,GAAiBT,UAAjB","file":"index.js","sourcesContent":["const less = require('less');\nconst pify = require('pify');\nconst processResult = require('./processResult');\nconst getOptions = require('./getOptions');\n\nconst render = pify(less.render.bind(less));\n\nfunction lessLoader(source) {\n const loaderContext = this;\n const options = getOptions(loaderContext);\n const done = loaderContext.async();\n const isSync = typeof done !== 'function';\n\n if (isSync) {\n throw new Error('Synchronous compilation is not supported anymore. See https://github.com/webpack-contrib/less-loader/issues/84');\n }\n\n processResult(loaderContext, render(source, options));\n}\n\nmodule.exports = lessLoader;\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/processResult.js"],"names":["removeSourceMappingUrl","require","formatLessError","processResult","loaderContext","resultPromise","callback","then","css","map","imports","forEach","addDependency","JSON","parse","lessError","module","exports"],"mappings":"AAAA,IAAMA,yBAAyBC,QAAQ,0BAAR,CAA/B;AACA,IAAMC,kBAAkBD,QAAQ,mBAAR,CAAxB;;AAEA;;;;;;AAMA,SAASE,aAAT,CAAuBC,aAAvB,EAAsCC,aAAtC,EAAqD;AAAA,MAC3CC,QAD2C,GAC9BF,aAD8B,CAC3CE,QAD2C;;;AAGnDD,gBACGE,IADH,CACQ,gBAA2B;AAAA,QAAxBC,GAAwB,QAAxBA,GAAwB;AAAA,QAAnBC,GAAmB,QAAnBA,GAAmB;AAAA,QAAdC,OAAc,QAAdA,OAAc;;AAC/BA,YAAQC,OAAR,CAAgBP,cAAcQ,aAA9B,EAA6CR,aAA7C;AACA,WAAO;AACL;AACA;AACAI,WAAKR,uBAAuBQ,GAAvB,CAHA;AAILC,WAAK,OAAOA,GAAP,KAAe,QAAf,GAA0BI,KAAKC,KAAL,CAAWL,GAAX,CAA1B,GAA4CA;AAJ5C,KAAP;AAMD,GATH,EASK,UAACM,SAAD,EAAe;AAChB,UAAMb,gBAAgBa,SAAhB,CAAN;AACD,GAXH,EAYGR,IAZH,CAYQ,iBAAkB;AAAA,QAAfC,GAAe,SAAfA,GAAe;AAAA,QAAVC,GAAU,SAAVA,GAAU;;AACtBH,aAAS,IAAT,EAAeE,GAAf,EAAoBC,GAApB;AACD,GAdH,EAcKH,QAdL;AAeD;;AAEDU,OAAOC,OAAP,GAAiBd,aAAjB","file":"processResult.js","sourcesContent":["const removeSourceMappingUrl = require('./removeSourceMappingUrl');\nconst formatLessError = require('./formatLessError');\n\n/**\n * Removes the sourceMappingURL from the generated CSS, parses the source map and calls the next loader.\n *\n * @param {loaderContext} loaderContext\n * @param {Promise<LessResult>} resultPromise\n */\nfunction processResult(loaderContext, resultPromise) {\n const { callback } = loaderContext;\n\n resultPromise\n .then(({ css, map, imports }) => {\n imports.forEach(loaderContext.addDependency, loaderContext);\n return {\n // Removing the sourceMappingURL comment.\n // See removeSourceMappingUrl.js for the reasoning behind this.\n css: removeSourceMappingUrl(css),\n map: typeof map === 'string' ? JSON.parse(map) : map,\n };\n }, (lessError) => {\n throw formatLessError(lessError);\n })\n .then(({ css, map }) => {\n callback(null, css, map);\n }, callback);\n}\n\nmodule.exports = processResult;\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/removeSourceMappingUrl.js"],"names":["matchSourceMappingUrl","removeSourceMappingUrl","content","replace","module","exports"],"mappings":"AAAA,IAAMA,wBAAwB,kCAA9B;;AAEA;;;;;;;;;;AAUA,SAASC,sBAAT,CAAgCC,OAAhC,EAAyC;AACvC,SAAOA,QAAQC,OAAR,CAAgBH,qBAAhB,EAAuC,EAAvC,CAAP;AACD;;AAEDI,OAAOC,OAAP,GAAiBJ,sBAAjB","file":"removeSourceMappingUrl.js","sourcesContent":["const matchSourceMappingUrl = /\\/\\*# sourceMappingURL=[^*]+\\*\\//;\n\n/**\n * Removes the sourceMappingURL comment. This is necessary because the less-loader\n * does not know where the final source map will be located. Thus, we remove every\n * reference to source maps. In a regular setup, the css-loader will embed the\n * source maps into the CommonJS module and the style-loader will translate it into\n * base64 blob urls.\n *\n * @param {string} content\n * @returns {string}\n */\nfunction removeSourceMappingUrl(content) {\n return content.replace(matchSourceMappingUrl, '');\n}\n\nmodule.exports = removeSourceMappingUrl;\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/stringifyLoader.js"],"names":["stringifyLoader","content","JSON","stringify","module","exports"],"mappings":"AAAA;;;;;;;AAOA,SAASA,eAAT,CAAyBC,OAAzB,EAAkC;AAChC,SAAOC,KAAKC,SAAL,CAAeF,OAAf,CAAP;AACD;;AAEDG,OAAOC,OAAP,GAAiBL,eAAjB","file":"stringifyLoader.js","sourcesContent":["/**\n * The stringifyLoader turns any content into a valid JavaScript string. This allows us to load any content\n * with loaderContext.loadModule() without webpack complaining about non-JS modules.\n *\n * @param {string} content\n * @return {string}\n */\nfunction stringifyLoader(content) {\n return JSON.stringify(content);\n}\n\nmodule.exports = stringifyLoader;\n"]}