rollup-plugin-copy-watch

raw JSON →
0.0.1 verified Mon Apr 27 auth: no javascript

A fork of rollup-plugin-copy (v3.4.0) that adds a `watch` option to watch additional sources (e.g., static assets) outside Rollup's bundle graph, triggering copy on change. Version 0.0.1 is the only release (unstable). It uses Chokidar for file watching and supports glob patterns, multiple targets, and flatten/hash options. Less maintained than the original; use for watch-mode copy only, else prefer rollup-plugin-copy.

error Error: Cannot find module 'chokidar'
cause chokidar is not listed as a peer dependency and may not be installed automatically.
fix
Run npm install chokidar --save-dev.
error TypeError: copy is not a function
cause Using named import { copy } instead of default import.
fix
Use import copy from 'rollup-plugin-copy-watch'.
breaking The 'watch' option must be explicitly set to enable source file watching; default is null (no watch).
fix Add `watch: 'your/path'` to the options object.
deprecated This package is a low-activity fork; prefer rollup-plugin-copy for production unless watch functionality is required.
fix Switch to rollup-plugin-copy if watch is not needed.
gotcha Chokidar options are not exposed; only 'watch' is passed to chokidar.watch().
fix Use rollup-plugin-copy with a separate watcher if full Chokidar control is needed.
npm install rollup-plugin-copy-watch
yarn add rollup-plugin-copy-watch
pnpm add rollup-plugin-copy-watch

Rollup config that copies HTML and images with watch on static folder.

import copy from 'rollup-plugin-copy-watch';

export default {
  input: 'src/index.js',
  output: { file: 'dist/app.js', format: 'cjs' },
  plugins: [
    copy({
      watch: 'static',
      targets: [
        { src: 'src/index.html', dest: 'dist/public' },
        { src: ['assets/images/**/*'], dest: 'dist/public/images' }
      ]
    })
  ]
};