Skip to content

Commit

Permalink
fix: 💥 make result unit to px
Browse files Browse the repository at this point in the history
  • Loading branch information
daief committed Nov 29, 2022
1 parent bddea6a commit f402067
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
20 changes: 19 additions & 1 deletion packages/develop/src/build/rollup-styles-plugin.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
import { Plugin } from 'rollup';
import postcss, { Plugin as PostcssPlugin } from 'postcss';

const postcss = require('postcss');
// const postcssJs = require('postcss-js');
const less = require('less');

const postcssRemToPx = (): PostcssPlugin => {
const base = 16;
return {
postcssPlugin: 'postcssRemToPx',
Rule(rule) {
rule.walkDecls((decl) => {
const reg = /(\d*\.?\d+)rem/gis;
const res = decl.value.matchAll(reg);
for (const it of res) {
const px = +it[1] * base + 'px';
decl.value = decl.value.replace(it[0], px);
}
});
},
};
};

export const createStylesPlugin = (tailwindConfig: any) => {
tailwindConfig = { ...tailwindConfig };
tailwindConfig.content = [];
Expand All @@ -23,6 +40,7 @@ export const createStylesPlugin = (tailwindConfig: any) => {
},
],
}),
postcssRemToPx(),
]);

const uid = (() => {
Expand Down
2 changes: 1 addition & 1 deletion packages/develop/src/build/rollup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function getRoolupConfig(opts: IBuildOptions) {

const components = fs
.readdirSync(workspace('src/components'))
.filter((cpt) => !['index.tsx', '_styles'].includes(cpt));
.filter((cpt) => !['index.tsx', '_styles', '_widgets'].includes(cpt));

const entries = components.reduce<Record<string, string>>((res, curr) => {
const p = `components/${curr}/index`;
Expand Down
2 changes: 1 addition & 1 deletion src/components/progress/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const radialProgressProps = {
},
size: {
type: [Number, String] as PropType<number | string>,
default: '5rem',
default: '80px',
},
thickness: {
type: [Number, String] as PropType<number | string>,
Expand Down

0 comments on commit f402067

Please sign in to comment.