feat(@vant/cli): using esbuild to minify css (#10204)

This commit is contained in:
neverland
2022-01-17 15:14:13 +08:00
committed by GitHub
parent 48de3ca50b
commit 71a2e26259
5 changed files with 8 additions and 17 deletions
@@ -1,15 +1,17 @@
import postcss from 'postcss';
import postcssrc from 'postcss-load-config';
import CleanCss from 'clean-css';
import { transform } from 'esbuild';
import { POSTCSS_CONFIG_FILE } from '../common/constant.js';
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;
const result = await transform(css, {
loader: 'css',
minify: true,
target: ['chrome53', 'safari10'],
});
return result.code;
}
-1
View File
@@ -1,7 +1,6 @@
// some modules with missing type definitions
declare module 'execa';
declare module 'hash-sum';
declare module 'clean-css';
declare module 'release-it';
declare module 'conventional-changelog';
declare module '@vant/markdown-vetur';