Rollup plugin to copy additional files and directories into the output directory of your Rollup bundle. The latest version 2.0.3 works with Rollup >=1.1.2. It maintains the relative directory hierarchy of copied assets. Key differentiators: simple API (just provide an array of paths), supports both files and directories, and works with chunked builds since v2.0.0. The plugin hooks into the generateBundle hook to copy assets. It has no other dependencies besides Rollup.
npm install rollup-plugin-copy-assetsVerified import paths — ran on the pinned version, not inferred.
Configures Rollup with the copy-assets plugin to copy a directory and a file to the output directory, preserving the relative structure.
Update to v2.0.0+ if you want overwrite behavior; if you relied on old behavior (no overwrite), you may need to use a different plugin.
Use absolute paths or paths relative to the project root. For glob patterns, consider rollup-plugin-copy (by rollup/plugins).
No fix needed; understand that assets are copied once per build, not per watch rebuild if only chunks change. Use rollup-plugin-copy for more granular control.
Consider using @rollup/plugin-copy from the official rollup/plugins monorepo, which is actively maintained.
Run npm install --save-dev rollup-plugin-copy-assets or yarn add --dev rollup-plugin-copy-assets.
Use import copy from 'rollup-plugin-copy-assets' instead of import { copy } from 'rollup-plugin-copy-assets'.Wrap the string in an array: { assets: ['src/assets'] }.