fix(cli): missing style deps if component doesn't have style

This commit is contained in:
陈嘉涵 2019-12-20 21:47:07 +08:00
parent 5389bcf4fb
commit b9a077b779
2 changed files with 7 additions and 1 deletions

View File

@ -1,4 +1,5 @@
import { join } from 'path';
import { existsSync } from 'fs-extra';
import { smartOutputFile } from '../common';
import { CSS_LANG, getCssBaseFile } from '../common/css';
import { SRC_DIR, STYPE_DEPS_JSON_FILE } from '../common/constant';
@ -27,12 +28,17 @@ export function genPacakgeStyle(options: Options) {
.map((name: string) => {
let path = join(SRC_DIR, `${name}/index${ext}`);
if (!existsSync(path)) {
return '';
}
if (options.pathResolver) {
path = options.pathResolver(path);
}
return `@import "${path}";`;
})
.filter((item: string) => !!item)
.join('\n');
smartOutputFile(options.outputPath, content);

View File

@ -99,7 +99,7 @@ export async function genStyleDepsMap() {
const map = {} as DepsMap;
components.filter(checkStyleExists).forEach(component => {
components.forEach(component => {
map[component] = analyzeComponentDeps(component);
});