Angular SSR Firebase hosting

Viewed 122

I've followed a tutorial and was able to set up Angular SSR. All works well. Now im trying to host it to firebase, but I can't seem to make it work.

Getting this error when i run firebase server - Error: Cannot find module D:\Git\Test-SSR\test-ssr-app\functions\dist\server

This is my index.json

import * as functions from "firebase-functions";

const universal = require(`${process.cwd()}\\dist\\server`).app();

export const ssr = functions.https.onRequest(universal);

This is my cp-angular.js

const fs = require('fs-extra');

(async() => {

    const src = '../dist';
    const copy = './dist';

    await fs.remove(copy);
    await fs.copy(src, copy);


})();

this is my package.json

{
  "name": "functions",
  "scripts": {
    "lint": "eslint --ext .js,.ts .",
    "build": "node cp-angular && tsc",
    "serve": "npm run build && firebase emulators:start --only functions",
    "shell": "npm run build && firebase functions:shell",
    "start": "npm run shell",
    "deploy": "firebase deploy --only functions",
    "logs": "firebase functions:log"
  },
  "engines": {
    "node": "12"
  },
  "main": "lib/index.js",
  "dependencies": {
    "firebase-admin": "^9.2.0",
    "firebase-functions": "^3.11.0",
    "fs-extra": "^10.0.0"
  },
  "devDependencies": {
    "@typescript-eslint/eslint-plugin": "^3.9.1",
    "@typescript-eslint/parser": "^3.8.0",
    "eslint": "^7.6.0",
    "eslint-config-google": "^0.14.0",
    "eslint-plugin-import": "^2.22.0",
    "firebase-functions-test": "^0.2.0",
    "typescript": "^3.8.0"
  },
  "private": true
}

I can see on the drive that the folder D:\Git\Test-SSR\test-ssr-app\functions\dist\server is present and there are some js files including a main.js.

What am I doing wrong here?

Any help is appreciated

0 Answers
Related