Skip to content

Commit b0c585b

Browse files
committed
feat: update
1 parent 2c38dd8 commit b0c585b

File tree

1 file changed

+30
-26
lines changed
  • src/built-in-plugins/project-analyse-pages/plugin

1 file changed

+30
-26
lines changed

src/built-in-plugins/project-analyse-pages/plugin/index.ts

+30-26
Original file line numberDiff line numberDiff line change
@@ -140,31 +140,33 @@ pri.project.onCreateEntry((analyseInfo: IResult, entry) => {
140140

141141
entry.pipeAppComponent(async entryComponent => {
142142
return `
143-
${(await Promise.all(
144-
analyseInfo.projectAnalysePages.pages
145-
.filter(page => !!page.file)
146-
.map(async page => {
147-
const pageRequirePath = normalizePath(
148-
path.relative(path.join(pri.projectRootPath, tempPath.dir), path.join(page.file.dir, page.file.name)),
149-
);
150-
151-
const importCode = `import(/* webpackChunkName: "${
152-
page.chunkName
153-
}" */ "${pageRequirePath}").then(code => {
143+
${(
144+
await Promise.all(
145+
analyseInfo.projectAnalysePages.pages
146+
.filter(page => !!page.file)
147+
.map(async page => {
148+
const pageRequirePath = normalizePath(
149+
path.relative(path.join(pri.projectRootPath, tempPath.dir), path.join(page.file.dir, page.file.name)),
150+
);
151+
152+
const importCode = `import(/* webpackChunkName: "${
153+
page.chunkName
154+
}" */ "${pageRequirePath}").then(code => {
154155
const filePath = "${path.format(page.file)}"
155156
156157
${await entry.pipe.get('afterPageLoad', '')}
157158
${await entry.pipe.get('returnPageInstance', 'return code.default')}
158159
})`;
159160
160-
return `
161+
return `
161162
const ${page.componentName} = Loadable<any, any>({
162163
loader: () => ${importCode},
163164
loading: (): any => null
164165
})\n
165166
`;
166-
}),
167-
)).join('\n')}
167+
}),
168+
)
169+
).join('\n')}
168170
${entryComponent}
169171
`;
170172
});
@@ -184,22 +186,24 @@ pri.project.onCreateEntry((analyseInfo: IResult, entry) => {
184186

185187
entry.pipeAppRoutes(async renderRoutes => {
186188
return `
187-
${(await Promise.all(
188-
analyseInfo.projectAnalysePages.pages.map(async page => {
189-
if (page.file) {
190-
return `
189+
${(
190+
await Promise.all(
191+
analyseInfo.projectAnalysePages.pages.map(async page => {
192+
if (page.file) {
193+
return `
191194
<${await entry.pipe.get('commonRoute', 'Route')} exact path="${page.routerPath}" component={${
192-
page.componentName
193-
}} />\n
195+
page.componentName
196+
}} />\n
194197
`;
195-
}
196-
if (page.redirect) {
197-
return `
198+
}
199+
if (page.redirect) {
200+
return `
198201
<Redirect from="${page.routerPath}" to="${page.redirect}" />\n
199202
`;
200-
}
201-
}),
202-
)).join('\n')}
203+
}
204+
}),
205+
)
206+
).join('\n')}
203207
${renderRoutes}
204208
`;
205209
});

0 commit comments

Comments
 (0)