plugins

Treeshaking

Remove composables from your client builds.

Unhead provides a Vite plugin to optimise your builds, by removing composables that aren't needed and simplifying your code.

While optional, it's recommended for most use cases to ensure Unhead runs optimally.

It will perform the following optimisations:

  • Remove server composables in client builds (e.g. useServerHead, useServerSeoMeta)
  • Transform useSeoMeta to raw useHead (saves ~3kb)

Usage

Install the addons package if you haven't already.

yarn
yarn add -D @unhead/addons

Vite

Add the Vite plugin to your build config.

// vite.config.ts
import { defineConfig } from 'vite'
import UnheadVite from '@unhead/addons/vite'
export default defineConfig({
  plugins: [
    UnheadVite(),
  ],
})

Webpack

// webpack.config.ts
import { UnheadWebpack } from '@unhead/addons/webpack'
export default {
  plugins: [
    UnheadWebpack(),
  ],
}