feat(cli): import base css

This commit is contained in:
陈嘉涵
2019-12-02 17:54:55 +08:00
parent 4299740b5d
commit 6a8a9a6f79
5 changed files with 111 additions and 30 deletions

View File

@@ -0,0 +1,33 @@
import { get } from 'lodash';
import { join, isAbsolute } from 'path';
import { CONFIG, STYLE_DIR, SRC_DIR } from './constant';
import { existsSync } from 'fs';
type CSS_LANG = 'css' | 'less' | 'scss';
function getCssLang(): CSS_LANG {
const preprocessor = get(CONFIG, 'build.css.preprocessor', 'less');
if (preprocessor === 'sass') {
return 'scss';
}
return preprocessor;
}
export const CSS_LANG = getCssLang();
export function getCssBaseFile() {
let path = join(STYLE_DIR, `base.${CSS_LANG}`);
const baseFile = get(CONFIG, 'build.css.base', '');
if (baseFile) {
path = isAbsolute(baseFile) ? baseFile : join(SRC_DIR, baseFile);
}
if (existsSync(path)) {
return path;
}
return null;
}