You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
1.1 KiB

4 years ago
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. /**
  7. * Creates new custom importers that use the given `resourcePath` if libsass calls the custom importer with `prev`
  8. * being 'stdin'.
  9. *
  10. * Why do we need this? We have to use the `data` option of node-sass in order to compile our sass because
  11. * the `resourcePath` might not be an actual file on disk. When using the `data` option, libsass uses the string
  12. * 'stdin' instead of a filename.
  13. *
  14. * We have to fix this behavior in order to provide a consistent experience to the webpack user.
  15. *
  16. * @param {Function|Array<Function>} importer
  17. * @param {string} resourcePath
  18. * @returns {Array<Function>}
  19. */
  20. function proxyCustomImporters(importer, resourcePath) {
  21. return [].concat(importer).map( // eslint-disable-next-line no-shadow
  22. importer => function customImporter() {
  23. return importer.apply(this, // eslint-disable-next-line prefer-rest-params
  24. Array.from(arguments).map((arg, i) => i === 1 && arg === 'stdin' ? resourcePath : arg));
  25. });
  26. }
  27. var _default = proxyCustomImporters;
  28. exports.default = _default;