mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
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
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user