{"id":22285,"library":"rollup-plugin-watch-assets","title":"rollup-plugin-watch-assets","description":"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.","status":"active","version":"1.0.1","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","rollup"],"install":[{"cmd":"npm install rollup-plugin-watch-assets","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-watch-assets","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-watch-assets","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Default export only; named import will be undefined.","wrong":"const { watchAssets } = require('rollup-plugin-watch-assets')","symbol":"default","correct":"import watchAssets from 'rollup-plugin-watch-assets'"},{"note":"Not a named export; use default import.","wrong":"import { watchAssets } from 'rollup-plugin-watch-assets'","symbol":"watchAssets","correct":"import watchAssets from 'rollup-plugin-watch-assets'"},{"note":"CommonJS works, but destructuring the named export fails.","wrong":"const { watchAssets } = require('rollup-plugin-watch-assets')","symbol":"require","correct":"const watchAssets = require('rollup-plugin-watch-assets')"}],"quickstart":{"code":"import watchAssets from 'rollup-plugin-watch-assets';\n\nexport default {\n  input: 'src/index.js',\n  output: {\n    dir: 'build',\n    format: 'es'\n  },\n  plugins: [\n    watchAssets({ assets: ['src/index.html', 'src/styles/*.css'] })\n  ]\n};","lang":"javascript","description":"Basic setup: import plugin, add to plugins array, specify asset paths/globs to watch."},"warnings":[{"fix":"Ensure Rollup runs in watch mode (--watch flag). Also verify glob patterns match existing files.","message":"Assets not triggering rebuilds if not already watched by Rollup (e.g., not imported). Plugin only adds to watcher; requires watch mode.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use absolute paths or resolve from project root: `path.resolve('src/...')`.","message":"Glob patterns relative to CWD, not relative to rollup.config.js. Misleading if config is in subdirectory.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Check compatibility; upgrade may require plugin rewrite.","message":"Only supports Rollup v2+; not tested with v3 or v4. API changes may break.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use `import watchAssets from 'rollup-plugin-watch-assets'` (no curly braces).","cause":"Named import instead of default import.","error":"TypeError: watchAssets is not a function"},{"fix":"Run `npm install rollup-plugin-watch-assets --save-dev`","cause":"Package not installed or not in node_modules.","error":"Error: Could not resolve 'rollup-plugin-watch-assets'"},{"fix":"Verify `assets` array contains valid globs (e.g., 'src/**/*.html') and files exist. Run rollup with --watch.","cause":"Plugin misconfigured or globs don't match existing files.","error":"Assets not triggering rebuild in watch mode"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}