Rollup plugin to copy files and folders during the build process, with glob support. Current stable version is 3.5.0. The plugin runs on the buildEnd hook by default, supports rename and transform of file contents, and can copy once in watch mode. It is actively maintained with regular releases. Key differentiators include synchronous copy option, flatten option to preserve directory structure, and TypeScript type definitions.
npm install rollup-plugin-copyVerified import paths — ran on the pinned version, not inferred.
Minimal rollup config to copy an HTML file and images using glob patterns with verbosity.
Upgrade target format: use targets: [{ src: 'file', dest: 'folder' }] instead of targets: ['file'] + outputFolder.If using an array of targets, provide an outputFolder option. If using generateBundle, set hook: 'generateBundle' explicitly.
Replace const copy = require('rollup-plugin-copy') with import copy from 'rollup-plugin-copy'.Set flatten: false in options to preserve folder structure.
Use copyOnce only when rolling with --watch to avoid duplicate copies.
Ensure targets is an array of objects: [{ src: 'path', dest: 'path' }].Use import copy from 'rollup-plugin-copy' (ESM) or const { default: copy } = require('rollup-plugin-copy') (CommonJS).Run npm install rollup-plugin-copy --save-dev or yarn add rollup-plugin-copy --dev.