-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
mfe-host.ts
35 lines (31 loc) · 1.14 KB
/
mfe-host.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import {
formatFiles,
generateFiles,
names,
Tree,
updateJson,
} from '@nrwl/devkit';
import { Schema } from './schema';
import applicationGenerator from '../application/application';
import { normalizeOptions } from '@nrwl/react/src/generators/application/lib/normalize-options';
import { runTasksInSerial } from '@nrwl/workspace/src/utilities/run-tasks-in-serial';
import { addMFEFiles } from '@nrwl/react/src/generators/mfe-host/lib/add-mfe';
import { NormalizedSchema } from '@nrwl/react/src/generators/application/schema';
export function updateProjectJson(host: Tree, options: NormalizedSchema) {
updateJson(host, `${options.appProjectRoot}/project.json`, (json) => {
json.targets.build.options[
'webpackConfig'
] = `${options.appProjectRoot}/webpack.config.js`;
return json;
});
}
export async function mfeHostGenerator(host: Tree, schema: Schema) {
const options = normalizeOptions(host, schema);
const initApp = await applicationGenerator(host, options);
addMFEFiles(host, options);
updateProjectJson(host, options);
if (!options.skipFormat) {
await formatFiles(host);
}
return runTasksInSerial(initApp);
}