Skip to content

Commit

Permalink
make port a number in angular.json
Browse files Browse the repository at this point in the history
  • Loading branch information
manfredsteyer committed Oct 10, 2020
1 parent 7421858 commit ab979a6
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 18 deletions.
2 changes: 1 addition & 1 deletion e2e/mf-e2e/tests/mf.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('mf e2e', () => {
fs.writeFileSync('tmp/nx-e2e/proj/angular.json', angularJson);
fs.mkdirSync('tmp/nx-e2e/proj/apps/shell');

await runNxCommandAsync(`generate @angular-architects/module-federation:init shell 5000`);
await runNxCommandAsync(`generate @angular-architects/module-federation:config shell 5000`);

expect(fs.existsSync('tmp/nx-e2e/proj/apps/shell/webpack.config.js')).toBeTruthy();
expect(fs.existsSync('tmp/nx-e2e/proj/apps/shell/webpack.prod.config.js')).toBeTruthy();
Expand Down
4 changes: 4 additions & 0 deletions packages/mf/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ Big thanks to the following people who helped to make this possible:

- Run **yarn** to install all packages

## Example

See https://github.com/manfredsteyer/module-federation-plugin-example

## More Details

Have a look at this [article series about Module Federation](https://www.angulararchitects.io/aktuelles/the-microfrontend-revolution-part-2-module-federation-with-angular/)
12 changes: 11 additions & 1 deletion packages/mf/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
{
"name": "@angular-architects/module-federation",
"version": "0.9.0",
"version": "0.9.3",
"access": "public",
"repository": {
"type": "GitHub",
"url": "https://github.com/angular-architects/module-federation-plugin"
},
"author": {
"name": "Manfred Steyer",
"email": "[email protected]",
"url": "https://www.angulararchitects.io"
},
"main": "src/index.js",
"schematics": "./collection.json",
"builders": "./builders.json",
Expand Down
1 change: 1 addition & 0 deletions packages/mf/src/create-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export function createConfig(projectName: string, root: string, port: number): s
},
plugins: [
new ModuleFederationPlugin({
// For remotes (please adjust)
/*
name: "${projectName}",
Expand Down
32 changes: 16 additions & 16 deletions packages/mf/src/schematics/mf/schematic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,26 +87,26 @@ export default function config (options: MfSchematicSchema): Rule {
tree.create(configPath, webpackConfig);
tree.create(configProdPath, prodConfig);

// const useYarn = (workspace.cli?.packageManager === 'yarn');
projectConfig.architect.build.options.extraWebpackConfig = configPath;
projectConfig.architect.build.configurations.production.extraWebpackConfig = configProdPath;
projectConfig.architect.serve.options.extraWebpackConfig = configPath;
projectConfig.architect.serve.options.port = port;
projectConfig.architect.serve.configurations.production.extraWebpackConfig = configProdPath;
projectConfig.architect.test.options.extraWebpackConfig = configPath;

// if (useYarn) {
// await yarnAdd('ngx-build-plus');
// }
// else {
// await npmInstall('ngx-build-plus');
// }
tree.overwrite('angular.json', JSON.stringify(workspace, null, '\t'));

return chain([
externalSchematic('ngx-build-plus', 'ng-add', { project: options.project }),
updateWorkspace((workspace) => {
const proj = workspace.projects.get(options.project);
proj.targets.get('build').options.extraWebpackConfig = configPath;
proj.targets.get('build').configurations.production.extraWebpackConfig = configProdPath;
proj.targets.get('serve').options.extraWebpackConfig = configPath;
proj.targets.get('serve').options.port = options.port;
proj.targets.get('serve').configurations.production.extraWebpackConfig = configProdPath;
proj.targets.get('test').options.extraWebpackConfig = configPath;
})
// updateWorkspace((workspace) => {
// const proj = workspace.projects.get(options.project);
// proj.targets.get('build').options.extraWebpackConfig = configPath;
// proj.targets.get('build').configurations.production.extraWebpackConfig = configProdPath;
// proj.targets.get('serve').options.extraWebpackConfig = configPath;
// proj.targets.get('serve').options.port = port;
// proj.targets.get('serve').configurations.production.extraWebpackConfig = configProdPath;
// proj.targets.get('test').options.extraWebpackConfig = configPath;
// })
]);

}
Expand Down

0 comments on commit ab979a6

Please sign in to comment.