mirror of
https://github.com/formbricks/formbricks.git
synced 2026-05-07 03:11:47 -05:00
476d032642
Co-authored-by: pandeymangg <anshuman.pandey9999@gmail.com>
32 lines
869 B
JavaScript
32 lines
869 B
JavaScript
// basic regex -- [whitespace](number)(rem)[whitespace or ;]
|
|
const REM_REGEX = /\b(\d+(\.\d+)?)(rem)\b/gi;
|
|
const PROCESSED = Symbol("processed");
|
|
|
|
const remtoEm = (opts = {}) => {
|
|
// This function converts rem units to em units in CSS declarations and media queries
|
|
const { transformMediaQuery = false } = opts;
|
|
|
|
return {
|
|
postcssPlugin: "postcss-rem-to-em-plugin",
|
|
Declaration(decl) {
|
|
if (!decl[PROCESSED]) {
|
|
decl.value = decl.value.replace(REM_REGEX, "$1em");
|
|
decl[PROCESSED] = true;
|
|
}
|
|
},
|
|
|
|
AtRule: {
|
|
media: (atRule) => {
|
|
if (!atRule[PROCESSED] && transformMediaQuery) {
|
|
atRule.params = atRule.params.replace(REM_REGEX, "$1em");
|
|
atRule[PROCESSED] = true;
|
|
}
|
|
},
|
|
},
|
|
};
|
|
};
|
|
|
|
module.exports = {
|
|
plugins: [require("tailwindcss"), require("autoprefixer"), remtoEm()],
|
|
};
|