weapp-tailwindcss
Version:
把 tailwindcss 原子化样式思想,带给小程序开发者们! bring tailwindcss to miniprogram developers!
58 lines (56 loc) • 1.53 kB
JavaScript
import {
ifdef,
ifndef,
matchCustomPropertyFromValue
} from "../chunk-RGXLY3HG.mjs";
import "../chunk-IM4NUFIU.mjs";
// src/css-macro/postcss.ts
var creator = () => {
return {
postcssPlugin: "postcss-weapp-tw-css-macro-plugin",
prepare() {
return {
AtRule(atRule, helper) {
if (atRule.name === "media") {
const values = [];
matchCustomPropertyFromValue(atRule.params, (arr) => {
values.push(arr[1]);
});
if (values.length > 0) {
const isNegative = atRule.params.includes("not");
const text = values.join(" ");
const comment = isNegative ? ifndef(text) : ifdef(text);
atRule.replaceWith([
helper.comment({
raws: {
before: "\n"
},
text: comment.start
}),
...atRule.nodes ?? [],
// .map((x) => x.clone()),
helper.comment({
raws: {
before: "\n"
},
text: comment.end
})
]);
}
}
},
CommentExit(comment) {
if (/#(?:ifn?def|endif)/.test(comment.text)) {
comment.raws.left = " ";
comment.raws.right = " ";
}
}
};
}
};
};
creator.postcss = true;
var postcss_default = creator;
export {
postcss_default as default
};