less-loader 4.0.6 → 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.
@@ -1,41 +0,0 @@
1
- 'use strict';
2
-
3
- var loaderUtils = require('loader-utils');
4
- var clone = require('clone');
5
- var createWebpackLessPlugin = require('./createWebpackLessPlugin');
6
-
7
- /**
8
- * Retrieves the options from the loaderContext, makes a deep copy of it and normalizes it for further consumption.
9
- *
10
- * @param {LoaderContext} loaderContext
11
- */
12
- function getOptions(loaderContext) {
13
- var options = Object.assign({
14
- plugins: [],
15
- relativeUrls: true,
16
- compress: Boolean(loaderContext.minimize)
17
- }, clone(loaderUtils.getOptions(loaderContext)));
18
-
19
- // We need to set the filename because otherwise our WebpackFileManager will receive an undefined path for the entry
20
- options.filename = loaderContext.resource;
21
-
22
- // When no paths are given, we use the webpack resolver
23
- if ('paths' in options === false) {
24
- // It's safe to mutate the array now because it has already been cloned
25
- options.plugins.push(createWebpackLessPlugin(loaderContext));
26
- }
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
-
38
- return options;
39
- }
40
-
41
- module.exports = getOptions;
@@ -1,38 +0,0 @@
1
- 'use strict';
2
-
3
- var removeSourceMappingUrl = require('./removeSourceMappingUrl');
4
- var formatLessError = require('./formatLessError');
5
-
6
- /**
7
- * Removes the sourceMappingURL from the generated CSS, parses the source map and calls the next loader.
8
- *
9
- * @param {loaderContext} loaderContext
10
- * @param {Promise<LessResult>} resultPromise
11
- */
12
- function processResult(loaderContext, resultPromise) {
13
- var callback = loaderContext.callback;
14
-
15
-
16
- resultPromise.then(function (_ref) {
17
- var css = _ref.css,
18
- map = _ref.map,
19
- imports = _ref.imports;
20
-
21
- imports.forEach(loaderContext.addDependency, loaderContext);
22
- return {
23
- // Removing the sourceMappingURL comment.
24
- // See removeSourceMappingUrl.js for the reasoning behind this.
25
- css: removeSourceMappingUrl(css),
26
- map: typeof map === 'string' ? JSON.parse(map) : map
27
- };
28
- }, function (lessError) {
29
- throw formatLessError(lessError);
30
- }).then(function (_ref2) {
31
- var css = _ref2.css,
32
- map = _ref2.map;
33
-
34
- callback(null, css, map);
35
- }, callback);
36
- }
37
-
38
- module.exports = processResult;
@@ -1,19 +0,0 @@
1
- 'use strict';
2
-
3
- var matchSourceMappingUrl = /\/\*# sourceMappingURL=[^*]+\*\//;
4
-
5
- /**
6
- * Removes the sourceMappingURL comment. This is necessary because the less-loader
7
- * does not know where the final source map will be located. Thus, we remove every
8
- * reference to source maps. In a regular setup, the css-loader will embed the
9
- * source maps into the CommonJS module and the style-loader will translate it into
10
- * base64 blob urls.
11
- *
12
- * @param {string} content
13
- * @returns {string}
14
- */
15
- function removeSourceMappingUrl(content) {
16
- return content.replace(matchSourceMappingUrl, '');
17
- }
18
-
19
- module.exports = removeSourceMappingUrl;
@@ -1,14 +0,0 @@
1
- "use strict";
2
-
3
- /**
4
- * The stringifyLoader turns any content into a valid JavaScript string. This allows us to load any content
5
- * with loaderContext.loadModule() without webpack complaining about non-JS modules.
6
- *
7
- * @param {string} content
8
- * @return {string}
9
- */
10
- function stringifyLoader(content) {
11
- return JSON.stringify(content);
12
- }
13
-
14
- module.exports = stringifyLoader;