How to place rem to vw #2950
Answered
by
asd8855
ShaneLee-9
asked this question in
Q&A
-
I want to replace all units with vw at once. In our project, we use I've done some searching, but unfortunately I didn't find a solution. |
Beta Was this translation helpful? Give feedback.
Answered by
asd8855
Sep 22, 2023
Replies: 1 comment 4 replies
-
class="w-16 md:w-32 lg:w-48 xl:w-52" ![]() |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Try it
// uno.config.ts
postprocess: [
(util) => {
// implement postcss-pxtorem
const pxRE = /(-?[.\d]+)px/g;
util.entries.forEach((entry) => {
const value = entry[1];
if (typeof value === 'string' && pxRE.test(value)) {
// 100 is [rootValue] of postcss-pxtorem in my project
// eslint-disable-next-line no-param-reassign
entry[1] = value.replace(pxRE, (_, pixelValue) =>
${pixelValue / 100}vw
);}
});
}
]