Registry / devops / rollup-plugin-watch-assets

rollup-plugin-watch-assets

JSON →
library1.0.1jsnpmunverified

A dead-simple Rollup plugin (v1.0.1, last updated 2022) that adds non-JS assets like HTML and CSS to Rollup's file watcher. Useful alongside copy plugins to trigger rebuilds when static files change. Accepts an array of filenames or globs. Lightweight alternative to manual watcher configuration or complex tooling. No dependencies beyond Rollup.

npm install rollup-plugin-watch-assets
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-WATC
R
rollup-plugin-watch-assets
devopsjavascriptv1.0.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import watchAssets from 'rollup-plugin-watch-assets'
const { watchAssets } = require('rollup-plugin-watch-assets')
Default export only; named import will be undefined.
watchAssets
import watchAssets from 'rollup-plugin-watch-assets'
import { watchAssets } from 'rollup-plugin-watch-assets'
Not a named export; use default import.
require
const watchAssets = require('rollup-plugin-watch-assets')
const { watchAssets } = require('rollup-plugin-watch-assets')
CommonJS works, but destructuring the named export fails.

Basic setup: import plugin, add to plugins array, specify asset paths/globs to watch.

import watchAssets from 'rollup-plugin-watch-assets'; export default { input: 'src/index.js', output: { dir: 'build', format: 'es' }, plugins: [ watchAssets({ assets: ['src/index.html', 'src/styles/*.css'] }) ] };
Debug
Known issues
gotchaAssets not triggering rebuilds if not already watched by Rollup (e.g., not imported). Plugin only adds to watcher; requires watch mode.
fix
Ensure Rollup runs in watch mode (--watch flag). Also verify glob patterns match existing files.
affects: >=1.0.0
gotchaGlob patterns relative to CWD, not relative to rollup.config.js. Misleading if config is in subdirectory.
fix
Use absolute paths or resolve from project root: `path.resolve('src/...')`.
affects: >=1.0.0
gotchaOnly supports Rollup v2+; not tested with v3 or v4. API changes may break.
fix
Check compatibility; upgrade may require plugin rewrite.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: watchAssets is not a function
Named import instead of default import.
fix
Use `import watchAssets from 'rollup-plugin-watch-assets'` (no curly braces).
Error: Could not resolve 'rollup-plugin-watch-assets'
Package not installed or not in node_modules.
fix
Run `npm install rollup-plugin-watch-assets --save-dev`
Assets not triggering rebuild in watch mode
Plugin misconfigured or globs don't match existing files.
fix
Verify `assets` array contains valid globs (e.g., 'src/**/*.html') and files exist. Run rollup with --watch.
Upgrade
Version history
1.0.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
rollup-plugin-watch-assets — npm install rollup-plugin-watch-assets · libregistry