From cee0bfa0e10f099f037b03a5b4c1de9ee9828be9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=98=89=E6=B6=B5?= Date: Wed, 18 Dec 2019 15:12:43 +0800 Subject: [PATCH] feat(cli): emit path of compile failed style --- .../vant-cli/src/compiler/compile-style.ts | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/packages/vant-cli/src/compiler/compile-style.ts b/packages/vant-cli/src/compiler/compile-style.ts index 8f15f4eba..d66e9e923 100644 --- a/packages/vant-cli/src/compiler/compile-style.ts +++ b/packages/vant-cli/src/compiler/compile-style.ts @@ -4,22 +4,28 @@ import { replaceExt } from '../common'; import { compileCss } from './compile-css'; import { compileLess } from './compile-less'; import { compileSass } from './compile-sass'; +import { logger } from '../common/logger'; async function compileFile(filePath: string) { const parsedPath = parse(filePath); - if (parsedPath.ext === '.less') { - const source = await compileLess(filePath); - return compileCss(source); - } + try { + if (parsedPath.ext === '.less') { + const source = await compileLess(filePath); + return await compileCss(source); + } - if (parsedPath.ext === '.scss') { - const source = await compileSass(filePath); - return compileCss(source); - } + if (parsedPath.ext === '.scss') { + const source = await compileSass(filePath); + return await compileCss(source); + } - const source = readFileSync(filePath, 'utf-8'); - return compileCss(source); + const source = readFileSync(filePath, 'utf-8'); + return await compileCss(source); + } catch (err) { + logger.error('Compile style failed: ' + filePath); + throw err; + } } export async function compileStyle(filePath: string) {