feat(cli): reload vant config

This commit is contained in:
陈嘉涵
2019-12-05 10:11:22 +08:00
parent b19b287276
commit 207089b2ca
8 changed files with 39 additions and 39 deletions
+7 -4
View File
@@ -1,12 +1,14 @@
import { get } from 'lodash';
import { join, isAbsolute } from 'path';
import { CONFIG, STYLE_DIR, SRC_DIR } from './constant';
import { existsSync } from 'fs';
import { join, isAbsolute } from 'path';
import { getVantConfig } from '../common';
import { STYLE_DIR, SRC_DIR } from './constant';
type CSS_LANG = 'css' | 'less' | 'scss';
function getCssLang(): CSS_LANG {
const preprocessor = get(CONFIG, 'build.css.preprocessor', 'less');
const vantConfig = getVantConfig();
const preprocessor = get(vantConfig, 'build.css.preprocessor', 'less');
if (preprocessor === 'sass') {
return 'scss';
@@ -18,9 +20,10 @@ function getCssLang(): CSS_LANG {
export const CSS_LANG = getCssLang();
export function getCssBaseFile() {
const vantConfig = getVantConfig();
let path = join(STYLE_DIR, `base.${CSS_LANG}`);
const baseFile = get(CONFIG, 'build.css.base', '');
const baseFile = get(vantConfig, 'build.css.base', '');
if (baseFile) {
path = isAbsolute(baseFile) ? baseFile : join(SRC_DIR, baseFile);
}