Last active
March 6, 2024 19:37
-
-
Save searls/d9ca494792736f94d765223c6ba98d33 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const css4ColorsToLegacyRgbaPlugin = { | |
postcssPlugin: 'these-colors-dont-run', | |
Once (root) { | |
root.walkDecls((decl) => { | |
const rgbRegex = /rgb\((\d{1,3})\s+(\d{1,3})\s+(\d{1,3})\s*(?:\/\s*(\d+\.?\d*))?\)/g | |
decl.value = decl.value.replace(rgbRegex, (match, r, g, b, a) => { | |
if (!a || a === '1' || a === '1.0') { | |
return `rgb(${r}, ${g}, ${b})` | |
} else { | |
return `rgba(${r}, ${g}, ${b}, ${a})` | |
} | |
}) | |
}) | |
} | |
} | |
module.exports = (api) => { | |
return { | |
plugins: [ | |
require('postcss-import'), | |
require('tailwindcss')({ | |
config: './config/tailwind.config.mailer.js' | |
}), | |
require('postcss-css-variables'), | |
css4ColorsToLegacyRgbaPlugin | |
] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment