import { u as upath } from './upath.mjs';
import { r as requireModule } from './cjs.mjs';
import { d as defineNuxtCommand, e as error } from './index.mjs';
import 'tty';

const build = defineNuxtCommand({
  meta: {
    name: "build",
    usage: "npx nuxi build [rootDir]",
    description: "Build nuxt for production deployment"
  },
  async invoke(args) {
    process.env.NODE_ENV = process.env.NODE_ENV || "production";
    const rootDir = upath.resolve(args._[0] || ".");
    const { loadNuxt, buildNuxt } = requireModule("@nuxt/kit", rootDir);
    const nuxt = await loadNuxt({ rootDir });
    nuxt.hook("error", (err) => {
      error("Nuxt Build Error:", err);
      process.exit(1);
    });
    await buildNuxt(nuxt);
  }
});

export { build as default };
