implemented release build

This commit is contained in:
Altair-sh
2026-09-29 18:56:04 +02:00
parent 7d64ab4809
commit 03eaa951f7
4 changed files with 78 additions and 0 deletions
+36
View File
@@ -0,0 +1,36 @@
/**
Assembles a self-contained deployment folder at ./build/ from the
`output: 'standalone'` next build output. Next.js does not include
.next/static or public/ in .next/standalone by itself, so this script
copies them in. The result can be deployed as-is and started with
`node server.js` from inside ./build/, without running `npm install`.
*/
import { cpSync, existsSync, rmSync } from 'node:fs'
import path from 'node:path'
const root = path.resolve(import.meta.dirname, '..')
const standaloneDir = path.join(root, '.next', 'standalone')
const buildDir = path.join(root, 'build')
if (!existsSync(standaloneDir)) {
console.error(
`${standaloneDir} not found. Run "next build" with output: 'standalone' set in next.config.ts first.`
)
process.exit(1)
}
rmSync(buildDir, { recursive: true, force: true })
cpSync(standaloneDir, buildDir, { recursive: true })
cpSync(
path.join(root, '.next', 'static'),
path.join(buildDir, '.next', 'static'),
{ recursive: true }
)
const publicDir = path.join(root, 'public')
if (existsSync(publicDir)) {
cpSync(publicDir, path.join(buildDir, 'public'), { recursive: true })
}
console.log(`build assembled at ${buildDir}`)