Configuration

Customize the Webpack build

Customize Webpack with a callback that preserves and returns its configuration. The documented calls cover client and server targets, including Node and Edge. The callback is not a Turbopack hook. Use explicit Webpack selection in a reviewed build; custom configuration may require maintenance across framework releases. Source: https://nextjs.org/docs/pages/api-reference/config/next-config-js/webpack. Documentation-reviewed illustrative draft; installed declarations and runtime not verified.

Formal Syntax & Structure

nextjs syntaxnextjs
webpack(config, context) returns config

Working Example

Example Snippetnextjs
import type {NextConfig} from 'next';const config:NextConfig={webpack(config){return config;}};export default config;
Next.js Reference