processTailwindFeatures.js 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. Object.defineProperty(exports, "default", {
  6. enumerable: true,
  7. get: function() {
  8. return processTailwindFeatures;
  9. }
  10. });
  11. const _normalizeTailwindDirectives = /*#__PURE__*/ _interop_require_default(require("./lib/normalizeTailwindDirectives"));
  12. const _expandTailwindAtRules = /*#__PURE__*/ _interop_require_default(require("./lib/expandTailwindAtRules"));
  13. const _expandApplyAtRules = /*#__PURE__*/ _interop_require_default(require("./lib/expandApplyAtRules"));
  14. const _evaluateTailwindFunctions = /*#__PURE__*/ _interop_require_default(require("./lib/evaluateTailwindFunctions"));
  15. const _substituteScreenAtRules = /*#__PURE__*/ _interop_require_default(require("./lib/substituteScreenAtRules"));
  16. const _resolveDefaultsAtRules = /*#__PURE__*/ _interop_require_default(require("./lib/resolveDefaultsAtRules"));
  17. const _collapseAdjacentRules = /*#__PURE__*/ _interop_require_default(require("./lib/collapseAdjacentRules"));
  18. const _collapseDuplicateDeclarations = /*#__PURE__*/ _interop_require_default(require("./lib/collapseDuplicateDeclarations"));
  19. const _partitionApplyAtRules = /*#__PURE__*/ _interop_require_default(require("./lib/partitionApplyAtRules"));
  20. const _setupContextUtils = require("./lib/setupContextUtils");
  21. const _featureFlags = require("./featureFlags");
  22. function _interop_require_default(obj) {
  23. return obj && obj.__esModule ? obj : {
  24. default: obj
  25. };
  26. }
  27. function processTailwindFeatures(setupContext) {
  28. return async function(root, result) {
  29. let { tailwindDirectives , applyDirectives } = (0, _normalizeTailwindDirectives.default)(root);
  30. // Partition apply rules that are found in the css
  31. // itself.
  32. (0, _partitionApplyAtRules.default)()(root, result);
  33. let context = setupContext({
  34. tailwindDirectives,
  35. applyDirectives,
  36. registerDependency (dependency) {
  37. result.messages.push({
  38. plugin: "tailwindcss",
  39. parent: result.opts.from,
  40. ...dependency
  41. });
  42. },
  43. createContext (tailwindConfig, changedContent) {
  44. return (0, _setupContextUtils.createContext)(tailwindConfig, changedContent, root);
  45. }
  46. })(root, result);
  47. if (context.tailwindConfig.separator === "-") {
  48. throw new Error("The '-' character cannot be used as a custom separator in JIT mode due to parsing ambiguity. Please use another character like '_' instead.");
  49. }
  50. (0, _featureFlags.issueFlagNotices)(context.tailwindConfig);
  51. await (0, _expandTailwindAtRules.default)(context)(root, result);
  52. // Partition apply rules that are generated by
  53. // addComponents, addUtilities and so on.
  54. (0, _partitionApplyAtRules.default)()(root, result);
  55. (0, _expandApplyAtRules.default)(context)(root, result);
  56. (0, _evaluateTailwindFunctions.default)(context)(root, result);
  57. (0, _substituteScreenAtRules.default)(context)(root, result);
  58. (0, _resolveDefaultsAtRules.default)(context)(root, result);
  59. (0, _collapseAdjacentRules.default)(context)(root, result);
  60. (0, _collapseDuplicateDeclarations.default)(context)(root, result);
  61. };
  62. }