export async function getRoutes()

in modules/builders/src/static-generator/utils.ts [20:50]


export async function getRoutes(
  options: PrerenderBuilderOptions,
  tsConfigPath: string | undefined,
  context: BuilderContext,
): Promise<string[]> {
  const { routes = [] } = options;
  const { logger, workspaceRoot } = context;
  if (options.routesFile) {
    const routesFilePath = path.join(workspaceRoot, options.routesFile);
    routes.push(
      ...fs
        .readFileSync(routesFilePath, 'utf8')
        .split(/\r?\n/)
        .filter((v) => !!v),
    );
  }

  if (options.guessRoutes && tsConfigPath) {
    try {
      routes.push(
        ...parseAngularRoutes(path.join(workspaceRoot, tsConfigPath))
          .map((routeObj) => routeObj.path)
          .filter((route) => !route.includes('*') && !route.includes(':')),
      );
    } catch (e) {
      logger.error('Unable to extract routes from application.', e);
    }
  }

  return [...routes.map((r) => (r === '' ? '/' : r))];
}