rollup-plugin-manifest-json
raw JSON → 1.7.0 verified Mon Apr 27 auth: no javascript
Rollup plugin that generates a web application manifest.json file for Progressive Web Apps (PWAs). It reads an existing manifest, optionally merges overrides, minifies the output, and emits it into the Rollup build directory. Version 1.7.0 (stable, maintained). Distinguishes itself by handling both input file cloning and direct manifest object merging, with built-in minification. Requires the manifest to be a valid JSON file or object. Compared to alternatives like vite-plugin-pwa, this is a focused, zero-dependency plugin for Rollup only.
Common errors
error Error: Could not read file: /path/to/manifest.json ENOENT: no such file or directory ↓
cause The manifest file specified in `input` does not exist.
fix
Create the manifest file at the specified path or correct the path in plugin options.
error TypeError: Cannot read properties of undefined (reading 'short_name') ↓
cause Accessing a property on the result before the plugin has emitted the file; no return value.
fix
Do not destructure or expect a return value from manifestJSON(); it emits a file into Rollup's output.
error Error: Could not load /path/to/manifest.json (imported by rollup-plugin-manifest-json): ENOENT ↓
cause The plugin tries to import the manifest file in older versions or misconfiguration.
fix
Ensure
input is a plain file path, not a module or URL. Warnings
gotcha The 'input' option is required and must point to an existing JSON file. If omitted or file missing, plugin throws. ↓
fix Ensure `input` is a valid path to a manifest JSON file.
gotcha The 'output' option defaults to 'public/manifest.json' regardless of Rollup output dir. The file is written relative to the project root. ↓
fix Set `output` to a path inside your Rollup output directory, e.g., `output: 'dist/manifest.webmanifest'`.
gotcha If both `input` file and `manifest` object provide the same key, the `manifest` object values overwrite the file values (deep merge not supported). ↓
fix Ensure `manifest` overrides are explicit; no nested merging.
gotcha Minification is enabled by default (minify: true). To preserve formatting, explicitly set `minify: false`. ↓
fix Add `minify: false` to options if you need a human-readable manifest.
Install
npm install rollup-plugin-manifest-json yarn add rollup-plugin-manifest-json pnpm add rollup-plugin-manifest-json Imports
- defaultExport wrong
const manifestJSON = require('rollup-plugin-manifest-json')correctimport manifestJSON from 'rollup-plugin-manifest-json' - ManifestOptions wrong
import { ManifestOptions } from 'rollup-plugin-manifest-json'correctimport type { ManifestOptions } from 'rollup-plugin-manifest-json' - plugin call wrong
manifestJSON('public/manifest.json', { short_name: 'Test' })correctmanifestJSON({ input: 'public/manifest.json', manifest: { short_name: 'Test' } })
Quickstart
import manifestJSON from 'rollup-plugin-manifest-json';
export default {
input: 'src/index.js',
output: {
dir: 'dist',
format: 'esm',
},
plugins: [
manifestJSON({
input: 'public/manifest.json', // required
minify: true,
manifest: {
short_name: 'MyApp',
name: 'My Application',
start_url: '/',
display: 'standalone',
background_color: '#ffffff',
theme_color: '#000000',
icons: [
{ src: 'icon-192.png', sizes: '192x192', type: 'image/png' },
{ src: 'icon-512.png', sizes: '512x512', type: 'image/png' },
],
},
}),
],
};