mirror of
https://github.com/youzan/vant.git
synced 2026-01-21 01:15:55 +08:00
feat(cli): import base css
This commit is contained in:
33
packages/vant-cli/src/common/css.ts
Normal file
33
packages/vant-cli/src/common/css.ts
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user