Files
formbricks/packages/surveys/postcss.config.cjs
Shubham Palriwala 0f95f1c98c feat: Revamp @formbricks/js package (#2299)
Co-authored-by: Matthias Nannt <mail@matthiasnannt.com>
2024-03-28 10:32:08 +00:00

32 lines
866 B
JavaScript

// basic regex -- [whitespace](number)(rem)[whitespace or ;]
const REM_REGEX = /(\d*\.?\d+\s?)(rem)/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()],
};