Skip to content

Commit

Permalink
feat: add export source when parse entry
Browse files Browse the repository at this point in the history
  • Loading branch information
SoloJiang committed Dec 11, 2020
1 parent d62211b commit 4cafa4a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
15 changes: 12 additions & 3 deletions packages/build-app-helpers/src/getMpaEntries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,24 @@ interface IOptions {
target: string;
appJsonPath: string;
}

interface IEntry {
entryPath: string;
entryName: string;
pageName: string;
source?: string;
}

// Get entries when exist app.json
export default function (api, options?: IOptions) {
export default function (api, options?: IOptions): IEntry[] {
const { target, appJsonPath } = options || {};
if (appJsonPath) {
return getEntriesByJson(api, target, appJsonPath);
}
return getEntriesByDir(api);
}

function getEntriesByJson(api, target, appJsonPath) {
function getEntriesByJson(api, target, appJsonPath): IEntry[] {
const {
context: { rootDir },
} = api;
Expand All @@ -35,6 +43,7 @@ function getEntriesByJson(api, target, appJsonPath) {
entryPath: getPageEntryByAppJson(rootDir, route.source),
entryName,
pageName,
source: route.source
};
});
}
Expand All @@ -48,7 +57,7 @@ function getPageEntryByAppJson(rootDir, source) {
return `${source}.${targetExt}`;
}

function getEntriesByDir(api: any) {
function getEntriesByDir(api: any): IEntry[] {
const {
context: { rootDir },
} = api;
Expand Down
2 changes: 1 addition & 1 deletion packages/build-app-helpers/src/getRoutesByAppJson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as fs from 'fs-extra';
interface IRoute {
targets?: string[];
source: string;
path?: string;
path: string;
name?: string;
}
interface IStaticConfig {
Expand Down

0 comments on commit 4cafa4a

Please sign in to comment.