Blame view

node_modules/less-loader/dist/processResult.js 1.06 KB
ce4c83ff   wxy   初始提交
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
  'use strict';
  
  var removeSourceMappingUrl = require('./removeSourceMappingUrl');
  var formatLessError = require('./formatLessError');
  
  /**
   * Removes the sourceMappingURL from the generated CSS, parses the source map and calls the next loader.
   *
   * @param {loaderContext} loaderContext
   * @param {Promise<LessResult>} resultPromise
   */
  function processResult(loaderContext, resultPromise) {
    var callback = loaderContext.callback;
  
  
    resultPromise.then(function (_ref) {
      var css = _ref.css,
          map = _ref.map,
          imports = _ref.imports;
  
      imports.forEach(loaderContext.addDependency, loaderContext);
      return {
        // Removing the sourceMappingURL comment.
        // See removeSourceMappingUrl.js for the reasoning behind this.
        css: removeSourceMappingUrl(css),
        map: typeof map === 'string' ? JSON.parse(map) : map
      };
    }, function (lessError) {
      throw formatLessError(lessError);
    }).then(function (_ref2) {
      var css = _ref2.css,
          map = _ref2.map;
  
      callback(null, css, map);
    }, callback);
  }
  
  module.exports = processResult;