helpers.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.plugin = exports.unshiftLoader = exports.loader = void 0;
  6. var _lodashCurry = _interopRequireDefault(require("next/dist/compiled/lodash.curry"));
  7. function _interopRequireDefault(obj) {
  8. return obj && obj.__esModule ? obj : {
  9. default: obj
  10. };
  11. }
  12. const loader = (0, _lodashCurry).default(function loader(rule, config) {
  13. var ref;
  14. if (!config.module) {
  15. config.module = {
  16. rules: []
  17. };
  18. }
  19. if (rule.oneOf) {
  20. var ref1;
  21. const existing = (ref1 = config.module.rules) == null ? void 0 : ref1.find((arrayRule)=>arrayRule && typeof arrayRule === "object" && arrayRule.oneOf);
  22. if (existing && typeof existing === "object") {
  23. existing.oneOf.push(...rule.oneOf);
  24. return config;
  25. }
  26. }
  27. (ref = config.module.rules) == null ? void 0 : ref.push(rule);
  28. return config;
  29. });
  30. exports.loader = loader;
  31. const unshiftLoader = (0, _lodashCurry).default(function unshiftLoader(rule, config) {
  32. var ref;
  33. if (!config.module) {
  34. config.module = {
  35. rules: []
  36. };
  37. }
  38. if (rule.oneOf) {
  39. var ref2;
  40. const existing = (ref2 = config.module.rules) == null ? void 0 : ref2.find((arrayRule)=>arrayRule && typeof arrayRule === "object" && arrayRule.oneOf);
  41. if (existing && typeof existing === "object") {
  42. var ref3;
  43. (ref3 = existing.oneOf) == null ? void 0 : ref3.unshift(...rule.oneOf);
  44. return config;
  45. }
  46. }
  47. (ref = config.module.rules) == null ? void 0 : ref.unshift(rule);
  48. return config;
  49. });
  50. exports.unshiftLoader = unshiftLoader;
  51. const plugin = (0, _lodashCurry).default(function plugin(p, config) {
  52. if (!config.plugins) {
  53. config.plugins = [];
  54. }
  55. config.plugins.push(p);
  56. return config;
  57. });
  58. exports.plugin = plugin;
  59. //# sourceMappingURL=helpers.js.map