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
@@ -1,30 +1,25 @@
import { get } from 'lodash';
import { join } from 'path';
import { writeFileSync } from 'fs-extra';
import { replaceExt } from '../common';
import { CSS_LANG, getCssBaseFile } from '../common/css';
import {
CONFIG,
SRC_DIR,
PACKAGE_STYLE_FILE,
STYPE_DEPS_JSON_FILE
} from '../common/constant';
export function getStyleExt(): string {
const preprocessor = get(CONFIG, 'build.css.preprocessor', 'less');
if (preprocessor === 'sass') {
return 'scss';
}
return preprocessor;
}
export function genPacakgeStyle() {
const styleDepsJson = require(STYPE_DEPS_JSON_FILE);
const ext = '.' + CSS_LANG;
const ext = '.' + getStyleExt();
let content = '';
const content = styleDepsJson.sequence
const baseFile = getCssBaseFile();
if (baseFile) {
content += `@import "${baseFile}";\n`;
}
content += styleDepsJson.sequence
.map((name: string) => `@import "${join(SRC_DIR, `${name}/index${ext}`)}";`)
.join('\n');