'use strict';

const consola = require('../shared/cli.81cce562.cjs');
const fs = require('../shared/cli.032c1382.cjs');
const banner = require('../shared/cli.80b03f33.cjs');
const index = require('../shared/cli.3e065eec.cjs');
const kit_bb49e233 = require('../shared/cli.de27c2e0.cjs');
require('events');
require('fs');
require('path');
require('util');
require('stream');
require('os');
require('node:fs');
require('node:module');
require('node:url');
require('node:fs/promises');
require('node:os');
require('crypto');
require('module');
require('perf_hooks');
require('vm');
require('url');
require('assert');
require('buffer');
require('tty');
require('node:path');
require('constants');
require('net');
require('child_process');
const prepare = require('../shared/cli.3ff03b85.cjs');
require('../shared/cli.cebce5ac.cjs');

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

exports.default = build;
