source: frontend/node_modules/tailwindcss/lib/postcss-plugins/nesting/plugin.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 3.2 KB
Line 
1"use strict";
2Object.defineProperty(exports, "__esModule", {
3 value: true
4});
5Object.defineProperty(exports, "nesting", {
6 enumerable: true,
7 get: function() {
8 return nesting;
9 }
10});
11const _postcss = /*#__PURE__*/ _interop_require_default(require("postcss"));
12const _postcssnested = /*#__PURE__*/ _interop_require_default(require("postcss-nested"));
13function _interop_require_default(obj) {
14 return obj && obj.__esModule ? obj : {
15 default: obj
16 };
17}
18function nesting(opts = _postcssnested.default) {
19 return (root, result)=>{
20 root.walkAtRules("screen", (rule)=>{
21 rule.name = "media";
22 rule.params = `screen(${rule.params})`;
23 });
24 root.walkAtRules("apply", (rule)=>{
25 rule.before(_postcss.default.decl({
26 prop: "__apply",
27 value: rule.params,
28 source: rule.source
29 }));
30 rule.remove();
31 });
32 let plugin = (()=>{
33 var _opts_hasOwnProperty;
34 if (typeof opts === "function" || typeof opts === "object" && (opts === null || opts === void 0 ? void 0 : (_opts_hasOwnProperty = opts.hasOwnProperty) === null || _opts_hasOwnProperty === void 0 ? void 0 : _opts_hasOwnProperty.call(opts, "postcssPlugin"))) {
35 return opts;
36 }
37 if (typeof opts === "string") {
38 return require(opts);
39 }
40 if (Object.keys(opts).length <= 0) {
41 return _postcssnested.default;
42 }
43 throw new Error("tailwindcss/nesting should be loaded with a nesting plugin.");
44 })();
45 (0, _postcss.default)([
46 plugin
47 ]).process(root, result.opts).sync();
48 root.walkDecls("__apply", (decl)=>{
49 decl.before(_postcss.default.atRule({
50 name: "apply",
51 params: decl.value,
52 source: decl.source
53 }));
54 decl.remove();
55 });
56 /**
57 * Use a private PostCSS API to remove the "clean" flag from the entire AST.
58 * This is done because running process() on the AST will set the "clean"
59 * flag on all nodes, which we don't want.
60 *
61 * This causes downstream plugins using the visitor API to be skipped.
62 *
63 * This is guarded because the PostCSS API is not public
64 * and may change in future versions of PostCSS.
65 *
66 * See https://github.com/postcss/postcss/issues/1712 for more details
67 *
68 * @param {import('postcss').Node} node
69 */ function markDirty(node) {
70 if (!("markDirty" in node)) {
71 return;
72 }
73 // Traverse the tree down to the leaf nodes
74 if (node.nodes) {
75 node.nodes.forEach((n)=>markDirty(n));
76 }
77 // If it's a leaf node mark it as dirty
78 // We do this here because marking a node as dirty
79 // will walk up the tree and mark all parents as dirty
80 // resulting in a lot of unnecessary work if we did this
81 // for every single node
82 if (!node.nodes) {
83 node.markDirty();
84 }
85 }
86 markDirty(root);
87 return root;
88 };
89}
Note: See TracBrowser for help on using the repository browser.