Unverified Commit a64130eb authored by Jude Gao's avatar Jude Gao Committed by GitHub

doc: add build lifecycle hooks documentation (#78842)

Added documentation for the new Build Lifecycle Hooks feature in the
Next.js Compiler, specifically the `runAfterProductionCompile` hook.

https://github.com/vercel/next.js/pull/77345
parent 6dbaf95a
......@@ -278,6 +278,29 @@ module.exports = {
}
```
### Build Lifecycle Hooks
The Next.js Compiler supports lifecycle hooks that allow you to run custom code at specific points during the build process. Currently, the following hook is supported:
#### runAfterProductionCompile
A hook function that executes after production build compilation finishes, but before running post-compilation tasks such as 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 tools to collect build outputs like sourcemaps.
```js filename="next.config.js"
module.exports = {
compiler: {
runAfterProductionCompile: async ({ distDir, projectDir }) => {
// Your custom code here
},
},
}
```
The hook receives an object with the following properties:
- `distDir`: The build output directory (defaults to `.next`)
- `projectDir`: The root directory of the project
## Experimental Features
### SWC Trace profiling
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment