How to deploy angular 4 universal app to firebase

With the introduction to angular 4 of universal, I can't figure out how to deploy the app successfully to a firebase hosting. I followed the steps here https://github.com/angular/angular-cli/wiki/stories-universal-rendering

I can't figure out this part of it though:

"The bundle produced has a hash in the filename from webpack. When deploying this to a production server, you will need to ensure the correct bundle is required, either by renaming the file or passing the bundle name as an argument to your server."

Usually we just use ng build --prod

Then firebase deploy the dist directory.

With this universal inclusion, which folder do I deploy to firebase?

dist-server or dist?


There is a youtube video from Google on this subject here: https://youtu.be/gxCu5TEmxXE

Basically, as far as I can tell at the moment there is no way of linking your functions folder with your 'dist' folder, so what we have to do is overwrite the firebase.json settings to serve your app as a function. This basically means that your function (expressJS code) is serving the app rather than the static files in dist/

After following the youtube video your firebase.json should be as follows:

{
  "hosting": {
    "public": "dist",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "rewrites": [
      {
        "source": "**",
        "function": "ssrapp"
      }
    ]
  },
  "functions": {
    "predeploy": "npm --prefix functions run build",
    "source": "functions"
  }
}
链接地址: http://www.djcxy.com/p/31350.html

上一篇: 角度cli通用渲染

下一篇: 如何将角度4通用应用程序部署到Firebase