Skip to main content

Optimization

File hashing

Use the bud.hash function to generate a hash for each file in the bundle. This hash will be added to outputted files.

bud.config.ts
import type {Bud} from '@roots/bud'

export default async (bud: Bud) => {
bud.hash()
}

Minimizing code

Use the bud.minimize function to run your application code through a minifier.

bud.config.ts
import type {Bud} from '@roots/bud'

export default async (bud: Bud) => {
bud.minimize()
}

Creating a runtime

You may create an application runtime using bud.runtime. Using the single option is probably the simplest and best solution for most applications (and is also the default):

bud.config.ts
import type {Bud} from '@roots/bud'

export default async (bud: Bud) => {
bud.runtime()
}

Creating a vendor chunk

Use dynamic imports

You should use dynamic imports to split your code into chunks that can be loaded on demand. This gives you more control over how your code is loaded and can improve performance.

You can perform general code splitting with bud.splitChunks.

bud.config.ts
import type {Bud} from '@roots/bud'

export default async (bud: Bud) => {
bud.splitChunks()
}

Optimizing images

You can optimize images using the @roots/bud-imagemin extension.

npm install @roots/bud-imagemin --save-dev