import { c as consola } from '../shared/cli.61828232.mjs';
import { o as overrideEnv, c as clearDir } from '../shared/cli.2b0f785a.mjs';
import { a as showVersions } from '../shared/cli.be931177.mjs';
import { d as defineRemixCommand } from '../shared/cli.d1d97f34.mjs';
import { r as resolve, a as loadRemix, b as buildRemix } from '../shared/cli.bf96fb69.mjs';
import 'events';
import 'fs';
import 'path';
import 'util';
import 'stream';
import 'os';
import 'node:fs';
import 'node:module';
import 'node:url';
import 'node:fs/promises';
import 'node:os';
import 'crypto';
import 'module';
import 'perf_hooks';
import 'vm';
import 'url';
import 'assert';
import 'buffer';
import 'tty';
import 'node:path';
import 'constants';
import 'net';
import 'child_process';
import { w as writeTypes } from '../shared/cli.7e6f7d0d.mjs';
import '../shared/cli.1da5a031.mjs';

const build = defineRemixCommand({
  meta: {
    name: "build",
    usage: "npx remix build [--dotenv] [rootDir]",
    description: "Build remix for production deployment"
  },
  async invoke(args) {
    overrideEnv("production");
    const cwd = resolve(args._[0] || ".");
    showVersions(cwd);
    const remix = await loadRemix({
      cwd,
      dotenv: {
        cwd,
        fileName: args.dotenv
      }
    });
    await clearDir(remix.options.buildDir);
    await writeTypes(remix);
    remix.hook("build:error", (err) => {
      consola.error("Remix Build Error:", err);
      process.exit(1);
    });
    await buildRemix(remix);
  }
});

export { build as default };
