Unhead Vite Plugin
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)
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.tsimport { defineConfig } from 'vite'import UnheadVite from '@unhead/addons/vite'export default defineConfig({ plugins: [ UnheadVite(), ],})
Webpack
// webpack.config.tsimport { UnheadWebpack } from '@unhead/addons/webpack'export default { plugins: [ UnheadWebpack(), ],}