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.

62 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. module.exports = {
  8. output: {
  9. uniqueName: "mef3",
  10. publicPath: "auto",
  11. },
  12. optimization: {
  13. runtimeChunk: false,
  14. },
  15. resolve: {
  16. alias: {
  17. ...sharedMappings.getAliases(),
  18. },
  19. },
  20. plugins: [
  21. new ModuleFederationPlugin({
  22. name: "mfe3",
  23. filename: "remoteEntry.js",
  24. exposes: {
  25. "./Module3": "./src/app/microfrontend3/microfrontend3.module.ts",
  26. },
  27. shared: share({
  28. "assets/img": { eager: 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", // 对应库的npm包名或本地路径
  53. requiredVersion: "*", // 或者具体的版本号,如"0.0.1"
  54. },
  55. ...sharedMappings.getDescriptors(),
  56. }),
  57. }),
  58. sharedMappings.getPlugin(),
  59. ],
  60. };