mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
16 lines
463 B
TypeScript
16 lines
463 B
TypeScript
import postcss from 'postcss';
|
|
import postcssrc from 'postcss-load-config';
|
|
import CleanCss from 'clean-css';
|
|
import { POSTCSS_CONFIG_FILE } from '../common/constant';
|
|
|
|
const cleanCss = new CleanCss();
|
|
|
|
export async function compileCss(source: string | Buffer) {
|
|
const config = await postcssrc({}, POSTCSS_CONFIG_FILE);
|
|
const { css } = await postcss(config.plugins as any).process(source, {
|
|
from: undefined,
|
|
});
|
|
|
|
return cleanCss.minify(css).styles;
|
|
}
|