Skip to content

Commit

Permalink
rem to em
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Wang <i@ryanc.cc>
  • Loading branch information
ruibaby committed Aug 8, 2024
1 parent 5fc02c6 commit c84833d
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion packages/search-widget/uno.config.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,29 @@
import {
defineConfig,
definePreset,
presetIcons,
presetUno,
transformerCompileClass,
transformerDirectives,
} from 'unocss';

const remRE = /(-?[.\d]+)rem/g;

const presetRemToEm = definePreset(() => {
return {
name: '@unocss/preset-rem-to-em',
postprocess: (util) => {
util.entries.forEach((i) => {
const value = i[1];
if (typeof value === 'string' && remRE.test(value))
i[1] = value.replace(remRE, (_, p1) => `${p1}em`);
});
},
};
});

export default defineConfig({
presets: [presetUno(), presetIcons()],
presets: [presetUno(), presetIcons(), presetRemToEm()],
transformers: [transformerDirectives(), transformerCompileClass()],
theme: {
colors: {
Expand Down

0 comments on commit c84833d

Please sign in to comment.