{"id":22288,"library":"rollup-plugin-watch-globs","title":"rollup-plugin-watch-globs","description":"A Rollup plugin that extends the watch mode to monitor arbitrary file globs (e.g., static assets, stylesheets, HTML) not in the module graph. Currently v2.0.1, maintained by Caleb Evans. Key differentiator: unlike relying on Rollup's default watch (which only tracks JS/TS files in the dependency graph), this plugin explicitly adds glob patterns to trigger rebuilds, complementing tools like rollup-plugin-copy. Released under MIT License, requires rollup >=2.0.0 as a peer dependency. A lightweight, focused solution with no runtime dependencies beyond rollup.","status":"active","version":"2.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/caleb531/rollup-plugin-watch-globs","tags":["javascript","rollup","rollup-plugin","watch"],"install":[{"cmd":"npm install rollup-plugin-watch-globs","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-watch-globs","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-watch-globs","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency >=2.0.0","package":"rollup","optional":false}],"imports":[{"note":"Default ESM export. CommonJS require() works only if package supports dual CJS/ESM; check your Rollup config's format.","wrong":"const watchGlobs = require('rollup-plugin-watch-globs')","symbol":"watchGlobs","correct":"import watchGlobs from 'rollup-plugin-watch-globs'"},{"note":"In CommonJS, you must use .default because the package exports an ESM default.","wrong":"const watchGlobs = require('rollup-plugin-watch-globs')","symbol":"watchGlobs","correct":"const watchGlobs = require('rollup-plugin-watch-globs').default"},{"note":"The function accepts an array of glob strings, not an options object.","wrong":"plugins: [watchGlobs({ patterns: [...] })]","symbol":"rollup.config.js","correct":"plugins: [watchGlobs([ 'public/**/*.*', 'src/styles/*.scss' ])]"}],"quickstart":{"code":"// rollup.config.js\nimport watchGlobs from 'rollup-plugin-watch-globs';\n\nexport default {\n  input: 'src/index.js',\n  output: {\n    dir: 'dist',\n    format: 'esm'\n  },\n  plugins: [\n    watchGlobs([\n      'public/**/*.*',\n      'src/styles/*.scss'\n    ])\n  ]\n};\n","lang":"javascript","description":"Shows how to import and configure watchGlobs with two glob patterns to watch static assets and stylesheets."},"warnings":[{"fix":"Ensure the argument is an array: watchGlobs(['**/*.css'])","message":"Glob patterns must be provided as an array of strings, not an object or single string.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Combine with appropriate plugins for actions on change.","message":"This plugin only adds file watching; it does not handle actual copying or processing of watched files (use e.g., rollup-plugin-copy).","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use import watchGlobs from 'rollup-plugin-watch-globs' and call it directly.","message":"v2.x changed the default export to be a callable function; previously it might have been a factory or object.","severity":"breaking","affected_versions":">=2.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 watchGlobs from 'rollup-plugin-watch-globs' (ESM) or const watchGlobs = require('rollup-plugin-watch-globs').default (CJS).","cause":"Incorrect import style (CommonJS without .default or wrong ESM import).","error":"TypeError: watchGlobs is not a function"},{"fix":"Wrap glob pattern in an array: watchGlobs(['public/**/*.*'])","cause":"Passed a string instead of an array of strings.","error":"Error: The 'watchGlobs' plugin hook 'watchChange' threw an error: Unexpected glob pattern"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}