Webpack

Payload has a Webpack (v5) bundler that you can build the Admin panel with. For now, we recommended using it because it is stable. If you are feeling a bit more adventurous you can give the Vite bundler a shot.

Out of the box, the Webpack bundler supports common functionalities such as SCSS and Typescript, but there are many cases where you may need to add support for additional functionalities.

Installation

yarn add @payloadcms/bundler-webpack

Import the bundler

// payload.config.ts
import { buildConfig } from 'payload/config'
import { webpackBundler } from '@payloadcms/bundler-webpack'
export default buildConfig({
admin: {
bundler: webpackBundler()
},
})

Extending Webpack

If you need to extend the Webpack config, you can do so by passing a function to the admin.webpack property on your Payload config. The function will receive the Webpack config as an argument and should return the modified config.

// payload.config.ts
import { buildConfig } from 'payload/config'
import { webpackBundler } from '@payloadcms/bundler-webpack'
export default buildConfig({
admin: {
bundler: webpackBundler()
webpack: (config) => {
// full control of the Webpack config
return config
},
},
})
Next

Vite