feat(cli): reload vant config

This commit is contained in:
陈嘉涵
2019-12-05 10:11:22 +08:00
parent b19b287276
commit 207089b2ca
8 changed files with 39 additions and 39 deletions
@@ -10,7 +10,7 @@ import {
import {
SRC_DIR,
DOCS_DIR,
CONFIG_FILE,
VANT_CONFIG_FILE,
SITE_DESKTOP_SHARED_FILE
} from '../common/constant';
@@ -51,7 +51,7 @@ function genExportDocuments(items: DocumentItem[]) {
}
function genImportConfig() {
return `import config from '${removeExt(CONFIG_FILE)}';`;
return `import config from '${removeExt(VANT_CONFIG_FILE)}';`;
}
function genExportConfig() {
@@ -1,11 +1,14 @@
import { join } from 'path';
import { existsSync } from 'fs-extra';
import { decamelize, pascalize, removeExt, getComponents, smartOutputFile } from '../common';
import { SRC_DIR, SITE_MODILE_SHARED_FILE } from '../common/constant';
import {
CONFIG,
SRC_DIR,
SITE_MODILE_SHARED_FILE
} from '../common/constant';
pascalize,
removeExt,
decamelize,
getVantConfig,
getComponents,
smartOutputFile
} from '../common';
type DemoItem = {
name: string;
@@ -34,16 +37,17 @@ function genExports(demos: DemoItem[]) {
}
function genConfig(demos: DemoItem[]) {
const vantConfig = getVantConfig();
const demoNames = demos.map(item => decamelize(item.name, '-'));
CONFIG.site.nav = CONFIG.site.nav.filter((group: any) => {
vantConfig.site.nav = vantConfig.site.nav.filter((group: any) => {
group.items = group.items.filter((item: any) =>
demoNames.includes(item.path)
);
return group.items.length;
});
return `export const config = ${JSON.stringify(CONFIG, null, 2)}`;
return `export const config = ${JSON.stringify(vantConfig, null, 2)}`;
}
function genCode(components: string[]) {