esbuild-plugin-assets-manifest

raw JSON →
1.0.8 verified Fri May 01 auth: no javascript

esbuild plugin that generates a JSON manifest file mapping entry points to their output assets (JS, CSS, images, etc.), similar to assets-webpack-plugin for Webpack. Version 1.0.8 is the latest stable release. It requires esbuild as a peer dependency, builds output based on esbuild's metafile, and supports custom filenames, output paths, metadata injection, and custom processing via processOutput. Key differentiators: lightweight, no extra runtime dependencies, focused solely on manifest generation, and fully typed with TypeScript definitions.

error Error: The plugin 'assets-manifest' must be called before build starts
cause Attempting to call the plugin function as if it were a class (e.g., new assetsManifest())
fix
Call the function directly without 'new': assetsManifest({...})
error TypeError: assetsManifest is not a function
cause Incorrect import syntax in ESM (e.g., using named import instead of default import)
fix
Use default import: import assetsManifest from 'esbuild-plugin-assets-manifest'
error Error: Build failed with 1 error: error: Invalid 'entryPoints': expected object
cause Passed entryPoints as an array instead of an object
fix
Change entryPoints to an object: { app: './src/app.js' }
gotcha Entry points must be an object (not array) for the manifest to include named entries.
fix Use entryPoints: { app: './src/app.js' } instead of entryPoints: ['./src/app.js'].
gotcha metafile must be set to true in esbuild options for the plugin to work.
fix Add metafile: true to your esbuild build options.
gotcha The plugin does not validate that the manifest path exists; ensure the output directory exists before build.
fix Create the directory manually or use a plugin like esbuild-plugin-copy to ensure it exists.
gotcha When using publicPath, ensure it ends with '/' to avoid missing slashes in asset URLs.
fix Set publicPath: '/static/' (trailing slash) instead of '/static'.
gotcha The manifest JSON may not include assets from code splitting or dynamic imports; only entry point outputs.
fix If code splitting is used, additional processing may be needed; no built-in support.
npm install esbuild-plugin-assets-manifest
yarn add esbuild-plugin-assets-manifest
pnpm add esbuild-plugin-assets-manifest

Builds an entry point and generates a manifest JSON file with custom metadata and indentation.

const esbuild = require('esbuild');
const assetsManifest = require('esbuild-plugin-assets-manifest');

await esbuild.build({
  entryPoints: { app: './src/index.js' },
  outdir: 'dist',
  bundle: true,
  metafile: true,
  plugins: [
    assetsManifest({
      filename: 'manifest.json',
      path: './dist',
      metadata: { version: '1.0.0', builtAt: new Date().toISOString() },
      processOutput: (assets) => JSON.stringify(assets, null, 2),
    })
  ]
});