Treeshaking Build Plugin
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 rawuseHead
(saves ~3kb)
Setup
- Install the
@unhead/addons
package.
yarn add -D @unhead/addons
npm install -D @unhead/addons
pnpm add -D @unhead/addons
- Add the plugin to your build config.
import UnheadVite from '@unhead/addons/vite'
import { defineConfig } from 'vite'
export default defineConfig({
plugins: [
UnheadVite(),
],
})
import { UnheadWebpack } from '@unhead/addons/webpack'
export default {
plugins: [
UnheadWebpack(),
],
}
Did this page help you?