chore(cli): split compilers

This commit is contained in:
陈嘉涵
2019-11-29 13:20:43 +08:00
parent e2c9628316
commit 51d2512311
9 changed files with 90 additions and 74 deletions

View File

@@ -0,0 +1,32 @@
import { get } from 'lodash';
import { join } from 'path';
import { writeFileSync } from 'fs-extra';
import { replaceExt } from '../common';
import {
CONFIG,
SRC_DIR,
PACKAGE_STYLE_FILE,
STYPE_DEPS_JSON_FILE
} from '../common/constant';
// eslint-disable-next-line
const styleDepsJson = require(STYPE_DEPS_JSON_FILE);
function getStyleExt(): string {
const preprocessor = get(CONFIG, 'build.css.preprocessor', 'less');
if (preprocessor === 'sass') {
return '.scss';
}
return `.${preprocessor}`;
}
export function genPacakgeStyle() {
const ext = getStyleExt();
const content = styleDepsJson.sequence
.map((name: string) => `@import "${join(SRC_DIR, `${name}/index${ext}`)}";`)
.join('\n');
writeFileSync(replaceExt(PACKAGE_STYLE_FILE, ext), content);
}