source: trip-planner-front/node_modules/less-loader/dist/index.js@ b738035

Last change on this file since b738035 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 2.4 KB
RevLine 
[6a3a178]1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.default = void 0;
7
8var _path = _interopRequireDefault(require("path"));
9
10var _options = _interopRequireDefault(require("./options.json"));
11
12var _utils = require("./utils");
13
14var _LessError = _interopRequireDefault(require("./LessError"));
15
16function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
18async function lessLoader(source) {
19 const options = this.getOptions(_options.default);
20 const callback = this.async();
21 const implementation = (0, _utils.getLessImplementation)(this, options.implementation);
22
23 if (!implementation) {
24 callback(new Error(`The Less implementation "${options.implementation}" not found`));
25 return;
26 }
27
28 const lessOptions = (0, _utils.getLessOptions)(this, options, implementation);
29 const useSourceMap = typeof options.sourceMap === "boolean" ? options.sourceMap : this.sourceMap;
30
31 if (useSourceMap) {
32 lessOptions.sourceMap = {
33 outputSourceFiles: true
34 };
35 }
36
37 let data = source;
38
39 if (typeof options.additionalData !== "undefined") {
40 data = typeof options.additionalData === "function" ? `${await options.additionalData(data, this)}` : `${options.additionalData}\n${data}`;
41 }
42
43 let result;
44
45 try {
46 result = await implementation.render(data, lessOptions);
47 } catch (error) {
48 if (error.filename) {
49 // `less` returns forward slashes on windows when `webpack` resolver return an absolute windows path in `WebpackFileManager`
50 // Ref: https://github.com/webpack-contrib/less-loader/issues/357
51 this.addDependency(_path.default.normalize(error.filename));
52 }
53
54 callback(new _LessError.default(error));
55 return;
56 }
57
58 delete lessOptions.pluginManager.webpackLoaderContext;
59 delete lessOptions.pluginManager;
60 const {
61 css,
62 imports
63 } = result;
64 imports.forEach(item => {
65 if ((0, _utils.isUnsupportedUrl)(item)) {
66 return;
67 } // `less` return forward slashes on windows when `webpack` resolver return an absolute windows path in `WebpackFileManager`
68 // Ref: https://github.com/webpack-contrib/less-loader/issues/357
69
70
71 this.addDependency(_path.default.normalize(item));
72 });
73 let map = typeof result.map === "string" ? JSON.parse(result.map) : result.map;
74
75 if (map && useSourceMap) {
76 map = (0, _utils.normalizeSourceMap)(map, this.rootContext);
77 }
78
79 callback(null, css, map);
80}
81
82var _default = lessLoader;
83exports.default = _default;
Note: See TracBrowser for help on using the repository browser.