Nuxt Build Cache

0.1.1 · active · verified Sun Apr 19

Nuxt Build Cache is an experimental module for Nuxt 3 designed to significantly accelerate CI/CD build processes by caching generated `.nuxt/` artifacts. Currently at version 0.1.1, its release cadence is irregular as it's under active development. The module works by collecting build outputs into a tar file after a `nuxt build`. On subsequent builds, it generates a content-based hash from various sources including Nuxt configuration, files in known Nuxt directories (like `pages/`, `layouts/`), and key project root files (`package.json`, lock-files). If this hash remains unchanged, it bypasses the Vite/Webpack build step and restores the cached build, potentially reducing build times by up to 2x. This mechanism is particularly beneficial when only prerendered content or server routes have changed, differentiating it from traditional file-based caching by focusing on a comprehensive content hash. It aims to replicate similar build performance improvements seen in Nuxt 2.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to add the `nuxt-build-cache` module using the Nuxt CLI and then configure it in your `nuxt.config.ts`.

npx nuxi module add nuxt-build-cache

// Then, in your nuxt.config.ts:
import { defineNuxtConfig } from 'nuxt';

export default defineNuxtConfig({
  modules: [
    'nuxt-build-cache'
  ],
  // Optional: Disable the cache entirely via environment variable
  // NUXT_DISABLE_BUILD_CACHE=true
  // Optional: Skip restoring cache even if it exists via environment variable
  // NUXT_IGNORE_BUILD_CACHE=true
});

view raw JSON →