export function generateFirebaseJson()

in src/schematics/setup/ssr.ts [51:83]


export function generateFirebaseJson(
  tree: Tree,
  path: string,
  project: string,
  dist: string,
  functionsOutput: string,
  functionName: string,
  projectType: PROJECT_TYPE,
) {
  const firebaseJson: FirebaseJSON = tree.exists(path)
    ? safeReadJSON(path, tree)
    : {};

  const newConfig = generateHostingConfig(project, dist, functionName, projectType);
  if (firebaseJson.hosting === undefined) {
    firebaseJson.hosting = [newConfig];
  } else if (Array.isArray(firebaseJson.hosting)) {
    const existingConfigIndex = firebaseJson.hosting.findIndex(config => config.target === newConfig.target);
    if (existingConfigIndex > -1) {
      firebaseJson.hosting.splice(existingConfigIndex, 1, newConfig);
    } else {
      firebaseJson.hosting.push(newConfig);
    }
  } else {
    firebaseJson.hosting = [firebaseJson.hosting, newConfig];
  }

  if (projectType === PROJECT_TYPE.CloudFunctions) {
    firebaseJson.functions = generateFunctionsConfig(functionsOutput);
  }

  overwriteIfExists(tree, path, stringifyFormatted(firebaseJson));
}