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.

63 lines
1.6 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. ]);
  8. module.exports = {
  9. output: {
  10. uniqueName: "mef2",
  11. publicPath: "auto",
  12. },
  13. optimization: {
  14. runtimeChunk: false,
  15. },
  16. resolve: {
  17. alias: {
  18. ...sharedMappings.getAliases(),
  19. },
  20. },
  21. plugins: [
  22. new ModuleFederationPlugin({
  23. name: "mfe2",
  24. filename: "remoteEntry.js",
  25. exposes: {
  26. "./Module1": "./src/app/microfrontend1/microfrontend1.module.ts",
  27. },
  28. shared: share({
  29. 'assets/img': { eager: true },
  30. "@angular/core": {
  31. singleton: true,
  32. strictVersion: true,
  33. requiredVersion: "auto",
  34. },
  35. "@angular/common": {
  36. singleton: true,
  37. strictVersion: true,
  38. requiredVersion: "auto",
  39. },
  40. "@angular/common/http": {
  41. singleton: true,
  42. strictVersion: true,
  43. requiredVersion: "auto",
  44. },
  45. "@angular/router": {
  46. singleton: true,
  47. strictVersion: true,
  48. requiredVersion: "auto",
  49. },
  50. 'my-shared': {
  51. singleton: true,
  52. strictVersion: true,
  53. import: 'my-shared', // 对应库的npm包名或本地路径
  54. requiredVersion: '*' // 或者具体的版本号,如"0.0.1"
  55. },
  56. ...sharedMappings.getDescriptors(),
  57. }),
  58. }),
  59. sharedMappings.getPlugin(),
  60. ],
  61. };