implemented release build
This commit is contained in:
@@ -1 +1,20 @@
|
|||||||
# paradox-save-parser-frontend
|
# paradox-save-parser-frontend
|
||||||
|
|
||||||
|
## Install dependencies
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm i
|
||||||
|
```
|
||||||
|
|
||||||
|
## Build release
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm run build
|
||||||
|
```
|
||||||
|
|
||||||
|
## Run release
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cd .next/standalone
|
||||||
|
node --enable-source-maps ./server.js
|
||||||
|
```
|
||||||
|
|||||||
@@ -2,7 +2,29 @@ import type { NextConfig } from 'next'
|
|||||||
|
|
||||||
const nextConfig: NextConfig = {
|
const nextConfig: NextConfig = {
|
||||||
experimental: {
|
experimental: {
|
||||||
|
// call tsc6 instead of import 'typescript'
|
||||||
useTypeScriptCli: true,
|
useTypeScriptCli: true,
|
||||||
|
// faster "npm run dev"
|
||||||
|
turbopackFileSystemCacheForDev: true,
|
||||||
|
// don't create temporary files in .next/ during "npm run build"
|
||||||
|
turbopackFileSystemCacheForBuild: false,
|
||||||
|
// options to make standalone build more debuggable
|
||||||
|
serverSourceMaps: true,
|
||||||
|
serverMinification: false,
|
||||||
|
},
|
||||||
|
// produce .next/standalone
|
||||||
|
// which can be started by `node server.js` without any dependencies
|
||||||
|
output: 'standalone',
|
||||||
|
images: {
|
||||||
|
unoptimized: true,
|
||||||
|
},
|
||||||
|
// remove next/image from build, which this project doesn't use
|
||||||
|
outputFileTracingExcludes: {
|
||||||
|
'*': ['node_modules/sharp/**', 'node_modules/@img/**'],
|
||||||
|
},
|
||||||
|
// sometimes production builds ran without proper type checking
|
||||||
|
typescript: {
|
||||||
|
ignoreBuildErrors: false,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
"dev": "cross-env NEXT_TELEMETRY_DISABLED=1 next dev --turbopack",
|
"dev": "cross-env NEXT_TELEMETRY_DISABLED=1 next dev --turbopack",
|
||||||
"prebuild": "node scripts/replace-tsc6-with-tsc7.mjs",
|
"prebuild": "node scripts/replace-tsc6-with-tsc7.mjs",
|
||||||
"build": "cross-env NEXT_TELEMETRY_DISABLED=1 next build",
|
"build": "cross-env NEXT_TELEMETRY_DISABLED=1 next build",
|
||||||
|
"postbuild": "node scripts/prepare-build.mjs",
|
||||||
"start": "next start",
|
"start": "next start",
|
||||||
"lint": "eslint",
|
"lint": "eslint",
|
||||||
"format": "npx prettier --write ."
|
"format": "npx prettier --write ."
|
||||||
|
|||||||
@@ -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}`)
|
||||||
Reference in New Issue
Block a user