如何在云端部署时访问 main.js 文件 n angular 项目

How to access main.js file n angular project on deployment over cloud

我正在为这个单个 spa 微前端应用程序开发一个 angular 项目,

{
      "imports": {
        "app1": "http://localhost:4201/main.js",
       "login": "http://localhost:4204/main.js",
      }
}

我已经在云上部署了我的 app1,但是在每个构建中都会生成不同的 main.js,就像这样 mainedsf24r43.js,因此我收到一个错误:

open() "/usr/share/nginx/html/main.js" failed (2: No such file or directory), client: 172.17.0.1, server: localhost, request: "GET /main.js HTTP/1.1", host: "localhost:8080", referrer: "http://localhost:4200/"

关于我们如何克服这个问题的任何解决方案。

如果您使用的是 angular-cli,只需在 angular.json

中将 projects.<projectName>.architect.build.configurations.production.outputHashing 设置为“none”