feat(cli): use clean-css to minify css

This commit is contained in:
陈嘉涵
2020-01-02 21:23:29 +08:00
parent bebe92705f
commit 6494795f81
3 changed files with 6 additions and 37 deletions

View File

@@ -1,13 +1,15 @@
import postcss from 'postcss';
import postcssrc from 'postcss-load-config';
import { minify } from 'csso';
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 minify(css).css;
return cleanCss.minify(css).styles;
}