mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
Add a `runAfterProductionCompile` hook in next.config.js that executes after production build compilation finishes, but before running post-compilation tasks like type checking and static page generation. This hook provides access to project metadata including the project directory and build output directory, making it useful for third-party to collect build outputs like sourcemaps.
22 lines
522 B
TypeScript
22 lines
522 B
TypeScript
import fs from 'fs/promises'
|
|
|
|
export async function after({
|
|
distDir,
|
|
projectDir,
|
|
}: {
|
|
distDir: string
|
|
projectDir: string
|
|
}) {
|
|
try {
|
|
console.log(`Using distDir: ${distDir}`)
|
|
console.log(`Using projectDir: ${projectDir}`)
|
|
|
|
await new Promise((resolve) => setTimeout(resolve, 5000))
|
|
|
|
const files = await fs.readdir(distDir, { recursive: true })
|
|
console.log(`Total files in ${distDir} folder: ${files.length}`)
|
|
} catch (err) {
|
|
console.error(`Error reading ${distDir} directory:`, err)
|
|
}
|
|
}
|