micro-front-end
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

74 lines
1.9 KiB

  1. const ModuleFederationPlugin = require('webpack/lib/container/ModuleFederationPlugin')
  2. const mf = require('@angular-architects/module-federation/webpack')
  3. const path = require('path')
  4. const share = mf.share
  5. const sharedMappings = new mf.SharedMappings()
  6. sharedMappings.register(path.join(__dirname, 'tsconfig.json'), [])
  7. module.exports = {
  8. output: {
  9. uniqueName: 'shell',
  10. publicPath: 'http://localhost:3000/',
  11. },
  12. optimization: {
  13. runtimeChunk: false,
  14. },
  15. resolve: {
  16. alias: {
  17. ...sharedMappings.getAliases(),
  18. },
  19. },
  20. plugins: [
  21. new ModuleFederationPlugin({
  22. remotes: {
  23. mfe1: 'mfe1@http://localhost:3001/remoteEntry.js',
  24. mfe2: 'mfe2@http://localhost:3002/remoteEntry.js',
  25. mfe3: 'mfe3@http://localhost:3003/remoteEntry.js',
  26. },
  27. shared: share({
  28. 'assets/img': { singleton: true },
  29. '@angular/core': {
  30. singleton: true,
  31. strictVersion: true,
  32. requiredVersion: 'auto',
  33. },
  34. '@angular/common': {
  35. singleton: true,
  36. strictVersion: true,
  37. requiredVersion: 'auto',
  38. },
  39. '@angular/common/http': {
  40. singleton: true,
  41. strictVersion: true,
  42. requiredVersion: 'auto',
  43. },
  44. '@angular/router': {
  45. singleton: true,
  46. strictVersion: true,
  47. requiredVersion: 'auto',
  48. },
  49. 'my-shared': {
  50. singleton: true,
  51. strictVersion: true,
  52. import: 'my-shared',
  53. requiredVersion: '*',
  54. },
  55. 'dynamic-core': {
  56. singleton: true,
  57. strictVersion: true,
  58. import: 'dynamic-core',
  59. requiredVersion: '*',
  60. },
  61. 'dynamic-components': {
  62. singleton: true,
  63. strictVersion: true,
  64. import: 'dynamic-components',
  65. requiredVersion: '*',
  66. },
  67. ...sharedMappings.getDescriptors(),
  68. }),
  69. }),
  70. sharedMappings.getPlugin(),
  71. ],
  72. }