async function main() {
  const reportGeneratorJs = await buildReportGenerator();

  const app = new GhPagesApp({
    name: 'viewer',
    appDir: `${LH_ROOT}/viewer/app`,
    html: {path: 'index.html'},
    stylesheets: [
      {path: 'styles/*'},
      {path: '../../flow-report/assets/styles.css'},
    ],
    javascripts: [
      // TODO: import report generator async
      // https://github.com/GoogleChrome/lighthouse/pull/13429
      reportGeneratorJs,
      {path: require.resolve('pako/dist/pako_inflate.js')},
      {path: 'src/main.js', esbuild: true, esbuildPlugins: [
        plugins.replaceModules({
          [`${LH_ROOT}/shared/localization/locales.js`]: 'export const locales = {};',
        }),
        plugins.ignoreBuiltins(),
        plugins.bulkLoader([
          plugins.partialLoaders.inlineFs({verbose: Boolean(process.env.DEBUG)}),
          plugins.partialLoaders.rmGetModuleDirectory,
        ]),
      ]},
    ],
    assets: [
      {path: 'images/**/*', destDir: 'images'},
      {path: 'manifest.json'},
      {path: '../../shared/localization/locales/*.json', destDir: 'locales'},
    ],
  });

  await app.build();

  const argv = process.argv.slice(2);
  if (argv.includes('--deploy')) {
    await app.deploy();
  }
}
Build viewer, optionally deploying to gh-pages if `--deploy` flag was set.