mirror of
https://github.com/youzan/vant.git
synced 2025-10-20 18:54:24 +00:00
chore(cli): split compilers
This commit is contained in:
@@ -1,21 +1,13 @@
|
||||
import { get } from 'lodash';
|
||||
import { join } from 'path';
|
||||
import { writeFileSync } from 'fs-extra';
|
||||
import { pascalize, getComponents, replaceExt } from '../common';
|
||||
import { pascalize, getComponents } from '../common';
|
||||
import {
|
||||
CONFIG,
|
||||
SRC_DIR,
|
||||
PACKAGE_JSON_FILE,
|
||||
PACKAGE_ENTRY_FILE,
|
||||
PACKAGE_STYLE_FILE,
|
||||
STYPE_DEPS_JSON_FILE
|
||||
PACKAGE_JSON,
|
||||
PACKAGE_ENTRY_FILE
|
||||
} from '../common/constant';
|
||||
|
||||
// eslint-disable-next-line
|
||||
const packageJson = require(PACKAGE_JSON_FILE);
|
||||
// eslint-disable-next-line
|
||||
const styleDepsJson = require(STYPE_DEPS_JSON_FILE);
|
||||
const version = process.env.PACKAGE_VERSION || packageJson.version;
|
||||
const version = process.env.PACKAGE_VERSION || PACKAGE_JSON.version;
|
||||
|
||||
function genImports(components: string[]): string {
|
||||
return components
|
||||
@@ -27,26 +19,7 @@ function genExports(names: string[]): string {
|
||||
return names.map(name => `${name}`).join(',\n ');
|
||||
}
|
||||
|
||||
function getStyleExt(): string {
|
||||
const preprocessor = get(CONFIG, 'build.css.preprocessor', 'less');
|
||||
|
||||
if (preprocessor === 'sass') {
|
||||
return '.scss';
|
||||
}
|
||||
|
||||
return `.${preprocessor}`;
|
||||
}
|
||||
|
||||
function genStyleEntry() {
|
||||
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);
|
||||
}
|
||||
|
||||
function genScriptEntry() {
|
||||
export function genPackageEntry() {
|
||||
const components = getComponents();
|
||||
const names = components.map(item => pascalize(item));
|
||||
|
||||
@@ -85,8 +58,3 @@ export default {
|
||||
|
||||
writeFileSync(PACKAGE_ENTRY_FILE, content);
|
||||
}
|
||||
|
||||
export function genPackageEntry() {
|
||||
genStyleEntry();
|
||||
genScriptEntry();
|
||||
}
|
||||
|
Reference in New Issue
Block a user