mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-25 02:41:46 +08:00
feat(cli): minify css
This commit is contained in:
parent
5318f3bd3f
commit
24202028e5
@ -27,6 +27,7 @@
|
|||||||
"vue-template-compiler": "^2.6.10"
|
"vue-template-compiler": "^2.6.10"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@types/csso": "^3.5.1",
|
||||||
"@types/eslint": "^6.1.3",
|
"@types/eslint": "^6.1.3",
|
||||||
"@types/fs-extra": "^8.0.1",
|
"@types/fs-extra": "^8.0.1",
|
||||||
"@types/html-webpack-plugin": "^3.2.1",
|
"@types/html-webpack-plugin": "^3.2.1",
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
import postcss from 'postcss';
|
import postcss from 'postcss';
|
||||||
import postcssrc from 'postcss-load-config';
|
import postcssrc from 'postcss-load-config';
|
||||||
|
import { minify } from 'csso';
|
||||||
import { POSTCSS_CONFIG_FILE } from '../common/constant';
|
import { POSTCSS_CONFIG_FILE } from '../common/constant';
|
||||||
|
|
||||||
export async function compileCss(source: string | Buffer) {
|
export async function compileCss(source: string | Buffer) {
|
||||||
const config = await postcssrc({}, POSTCSS_CONFIG_FILE);
|
const config = await postcssrc({}, POSTCSS_CONFIG_FILE);
|
||||||
const output = await postcss(config.plugins as any).process(source, {
|
const { css } = await postcss(config.plugins as any).process(source, {
|
||||||
from: undefined
|
from: undefined
|
||||||
});
|
});
|
||||||
|
|
||||||
return output;
|
return minify(css).css;
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ async function compileFile(filePath: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function compileStyle(filePath: string) {
|
export async function compileStyle(filePath: string) {
|
||||||
const content = await compileFile(filePath);
|
const css = await compileFile(filePath);
|
||||||
|
|
||||||
writeFileSync(replaceExt(filePath, '.css'), content);
|
writeFileSync(replaceExt(filePath, '.css'), css);
|
||||||
}
|
}
|
||||||
|
@ -1252,6 +1252,18 @@
|
|||||||
dependencies:
|
dependencies:
|
||||||
"@types/node" "*"
|
"@types/node" "*"
|
||||||
|
|
||||||
|
"@types/css-tree@*":
|
||||||
|
version "1.0.3"
|
||||||
|
resolved "https://registry.yarnpkg.com/@types/css-tree/-/css-tree-1.0.3.tgz#69112ebce09f582c9e0f32a46de2598930847cd7"
|
||||||
|
integrity sha512-ScS4V2j9vL6aMzCIPxJLGKqyslg8zEj+XkzUXCDMHbFftakwEl9WL6RBj3VBTH4O+EVwUM3umZTwu0ZedXyuaA==
|
||||||
|
|
||||||
|
"@types/csso@^3.5.1":
|
||||||
|
version "3.5.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/@types/csso/-/csso-3.5.1.tgz#f923bc919bfc89c1b5d149cff80d7bfb5e8e1e8d"
|
||||||
|
integrity sha512-NnALC1ZR5H4kg/9wUOa8/U2HOAwN4O71Av90HClgCteuwj6UHBEr37I0Cl10EY2gHd5p/JtsbY2r0WbOhYN+gw==
|
||||||
|
dependencies:
|
||||||
|
"@types/css-tree" "*"
|
||||||
|
|
||||||
"@types/eslint-visitor-keys@^1.0.0":
|
"@types/eslint-visitor-keys@^1.0.0":
|
||||||
version "1.0.0"
|
version "1.0.0"
|
||||||
resolved "https://registry.npm.taobao.org/@types/eslint-visitor-keys/download/@types/eslint-visitor-keys-1.0.0.tgz?cache=0&sync_timestamp=1572470950582&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40types%2Feslint-visitor-keys%2Fdownload%2F%40types%2Feslint-visitor-keys-1.0.0.tgz#1ee30d79544ca84d68d4b3cdb0af4f205663dd2d"
|
resolved "https://registry.npm.taobao.org/@types/eslint-visitor-keys/download/@types/eslint-visitor-keys-1.0.0.tgz?cache=0&sync_timestamp=1572470950582&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40types%2Feslint-visitor-keys%2Fdownload%2F%40types%2Feslint-visitor-keys-1.0.0.tgz#1ee30d79544ca84d68d4b3cdb0af4f205663dd2d"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user