less-loader 4.0.1 → 4.0.5

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,41 @@
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.0.5"></a>
6
+ ## [4.0.5](https://github.com/webpack-contrib/less-loader/compare/v4.0.4...v4.0.5) (2017-07-10)
7
+
8
+
9
+
10
+ <a name="4.0.4"></a>
11
+ ## [4.0.4](https://github.com/webpack-contrib/less-loader/compare/v4.0.3...v4.0.4) (2017-05-30)
12
+
13
+
14
+ ### Bug Fixes
15
+
16
+ * 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)
17
+
18
+
19
+
20
+ <a name="4.0.3"></a>
21
+ ## [4.0.3](https://github.com/webpack-contrib/less-loader/compare/v4.0.2...v4.0.3) (2017-03-30)
22
+
23
+
24
+ ### Bug Fixes
25
+
26
+ * sourcesContent missing in source maps ([df28035](https://github.com/webpack-contrib/less-loader/commit/df28035))
27
+
28
+
29
+
30
+ <a name="4.0.2"></a>
31
+ ## [4.0.2](https://github.com/webpack-contrib/less-loader/compare/v4.0.1...v4.0.2) (2017-03-21)
32
+
33
+
34
+ ### Bug Fixes
35
+
36
+ * Plugin.install is not a function ([f8ae245](https://github.com/webpack-contrib/less-loader/commit/f8ae245))
37
+
38
+
39
+
5
40
  <a name="4.0.1"></a>
6
41
  ## [4.0.1](https://github.com/webpack-contrib/less-loader/compare/v4.0.0...v4.0.1) (2017-03-21)
7
42
 
package/README.md CHANGED
@@ -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"); } }
@@ -56,7 +58,7 @@ function createWebpackLessPlugin(loaderContext) {
56
58
  value: function loadFile(filename, currentDirectory /* , options, environment */) {
57
59
  // eslint-disable-line class-methods-use-this
58
60
  var url = filename.replace(matchMalformedModuleFilename, '$1');
59
- var moduleRequest = loaderUtils.urlToRequest(url);
61
+ var moduleRequest = loaderUtils.urlToRequest(url, url.charAt(0) === '/' ? '' : null);
60
62
  // Less is giving us trailing slashes, but the context should have no trailing slash
61
63
  var context = currentDirectory.replace(trailingSlash, '');
62
64
  var resolvedFilename = void 0;
@@ -92,5 +94,4 @@ function createWebpackLessPlugin(loaderContext) {
92
94
  };
93
95
  }
94
96
 
95
- module.exports = createWebpackLessPlugin;
96
- //# sourceMappingURL=createWebpackLessPlugin.js.map
97
+ 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,5 +1,7 @@
1
+ 'use strict';
2
+
1
3
  var loaderUtils = require('loader-utils');
2
- var cloneDeep = require('clone-deep');
4
+ var clone = require('clone');
3
5
  var createWebpackLessPlugin = require('./createWebpackLessPlugin');
4
6
 
5
7
  /**
@@ -12,7 +14,7 @@ function getOptions(loaderContext) {
12
14
  plugins: [],
13
15
  relativeUrls: true,
14
16
  compress: Boolean(loaderContext.minimize)
15
- }, cloneDeep(loaderUtils.getOptions(loaderContext)));
17
+ }, clone(loaderUtils.getOptions(loaderContext)));
16
18
 
17
19
  // We need to set the filename because otherwise our WebpackFileManager will receive an undefined path for the entry
18
20
  options.filename = loaderContext.resource;
@@ -23,8 +25,17 @@ function getOptions(loaderContext) {
23
25
  options.plugins.push(createWebpackLessPlugin(loaderContext));
24
26
  }
25
27
 
28
+ if (options.sourceMap) {
29
+ if (typeof options.sourceMap === 'boolean') {
30
+ options.sourceMap = {};
31
+ }
32
+ if ('outputSourceFiles' in options.sourceMap === false) {
33
+ // Include source files as `sourceContents` as sane default since this makes source maps "just work" in most cases
34
+ options.sourceMap.outputSourceFiles = true;
35
+ }
36
+ }
37
+
26
38
  return options;
27
39
  }
28
40
 
29
- module.exports = getOptions;
30
- //# 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,65 +1,65 @@
1
1
  {
2
2
  "name": "less-loader",
3
- "version": "4.0.1",
3
+ "version": "4.0.5",
4
4
  "author": "Johannes Ewald @jhnns",
5
5
  "description": "Less loader for webpack. Compiles Less to CSS.",
6
- "main": "dist/index.js",
6
+ "main": "dist/cjs.js",
7
7
  "scripts": {
8
8
  "create-spec": "babel-node test/helpers/createSpec.js",
9
9
  "pretest": "npm run create-spec",
10
10
  "test": "jest",
11
11
  "posttest": "npm run lint",
12
- "travis:test": "yarn run test",
13
- "appveyor:test": "npm test",
12
+ "travis:test": "npm run test -- --runInBand",
13
+ "appveyor:test": "npm run test",
14
14
  "lint": "eslint --cache src test",
15
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",
16
+ "start": "npm run build -- -w",
17
+ "build": "cross-env NODE_ENV=production babel src -d dist --ignore 'src/**/*.test.js'",
19
18
  "lint-staged": "lint-staged",
20
- "prebuild": "yarn run clean:dist",
21
- "prepublish": "yarn run build",
22
- "release": "yarn run standard-version",
19
+ "prebuild": "npm run clean",
20
+ "prepublish": "npm run build",
21
+ "release": "standard-version",
23
22
  "security": "nsp check",
24
- "serve:dev": "nodemon $2 --exec babel-node",
25
23
  "test:watch": "jest --watch",
26
24
  "test:coverage": "jest --collectCoverageFrom='src/**/*.js' --coverage",
27
- "travis:coverage": "yarn run test:coverage",
28
- "travis:lint": "yarn run lint && yarn run security"
25
+ "pretravis:coverage": "npm run pretest",
26
+ "travis:coverage": "npm run test:coverage -- --runInBand",
27
+ "travis:lint": "npm run lint && npm run security",
28
+ "clean": "del-cli dist"
29
29
  },
30
30
  "engines": {
31
- "node": ">=4.3 <5.0.0 || >=5.10"
31
+ "node": ">= 4.3 < 5.0.0 || >= 5.10"
32
32
  },
33
33
  "dependencies": {
34
- "clone-deep": "^0.2.4",
35
- "loader-utils": "^1.0.2",
34
+ "clone": "^2.1.1",
35
+ "loader-utils": "^1.1.0",
36
36
  "pify": "^2.3.0"
37
37
  },
38
38
  "peerDependencies": {
39
39
  "less": "^2.3.1",
40
- "webpack": "^2.2.0"
40
+ "webpack": "^2.0.0 || ^3.0.0"
41
41
  },
42
42
  "devDependencies": {
43
43
  "babel-cli": "^6.24.0",
44
- "babel-jest": "^19.0.0",
44
+ "babel-jest": "^20.0.3",
45
45
  "babel-plugin-transform-object-rest-spread": "^6.23.0",
46
46
  "babel-polyfill": "^6.23.0",
47
- "babel-preset-env": "^1.2.1",
47
+ "babel-preset-env": "^1.2.2",
48
48
  "cross-env": "^3.2.4",
49
49
  "del-cli": "^0.2.1",
50
- "eslint": "^3.17.1",
51
- "eslint-config-webpack": "^1.1.0",
50
+ "eslint": "^3.18.0",
51
+ "eslint-config-webpack": "^1.2.1",
52
52
  "eslint-plugin-import": "^2.2.0",
53
53
  "inspect-loader": "^1.0.0",
54
- "jest": "^19.0.2",
54
+ "jest": "^20.0.3",
55
55
  "less": "^2.3.1",
56
56
  "lint-staged": "^3.4.0",
57
57
  "nodemon": "^1.11.0",
58
58
  "nsp": "^2.6.3",
59
59
  "pre-commit": "^1.2.2",
60
60
  "standard-version": "^4.0.0",
61
- "webpack": "^2.2.0",
62
- "webpack-defaults": "^0.4.1"
61
+ "webpack": "latest",
62
+ "webpack-defaults": "^1.0.1"
63
63
  },
64
64
  "repository": {
65
65
  "type": "git",
@@ -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","cloneDeep","createWebpackLessPlugin","getOptions","loaderContext","options","plugins","relativeUrls","compress","Boolean","minimize","filename","resource","push","module","exports"],"mappings":"AAAA,IAAMA,cAAcC,QAAQ,cAAR,CAApB;AACA,IAAMC,YAAYD,QAAQ,YAAR,CAAlB;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,UAAUF,YAAYI,UAAZ,CAAuBC,aAAvB,CAAV,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,SAAOC,OAAP;AACD;;AAEDS,OAAOC,OAAP,GAAiBZ,UAAjB","file":"getOptions.js","sourcesContent":["const loaderUtils = require('loader-utils');\nconst cloneDeep = require('clone-deep');\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 ...cloneDeep(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 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"]}