Registry / devops / rollup-plugin-copy-assets

rollup-plugin-copy-assets

JSON →
library2.0.3jsnpmunverified

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-assets
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-COPY
R
rollup-plugin-copy-assets
devopsjavascriptv2.0.3
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

copy
import copy from 'rollup-plugin-copy-assets'
const copy = require('rollup-plugin-copy-assets').default
CommonJS users should use const copy = require('rollup-plugin-copy-assets'); note the .default is not needed.
default export
import copy from 'rollup-plugin-copy-assets'
import { copy } from 'rollup-plugin-copy-assets'
The plugin is a default export, not a named export.
require (CJS)
const copy = require('rollup-plugin-copy-assets');
const copy = require('rollup-plugin-copy-assets').default;
Since it's a default export in ESM, the CommonJS require returns the default directly.
TypeScript usage
import copy from 'rollup-plugin-copy-assets'
If using TypeScript, you may need to install @types/rollup-plugin-copy-assets or define types manually as the package does not ship its own types.

Configures Rollup with the copy-assets plugin to copy a directory and a file to the output directory, preserving the relative structure.

// rollup.config.js import copy from 'rollup-plugin-copy-assets'; export default { input: 'src/index.js', output: { dir: 'dist', format: 'cjs' }, plugins: [ copy({ assets: [ 'src/assets', 'src/external/buffer.bin' ] }) ] };
Debug
Known issues
breakingv2.0.0 changed behavior: assets now overwrite existing files in output directory.
fix
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.
affects: <2.0.0
gotchaThe `assets` option does not support glob patterns or relative paths outside the project root (e.g., '../foo').
fix
Use absolute paths or paths relative to the project root. For glob patterns, consider rollup-plugin-copy (by rollup/plugins).
affects: *
gotchaPlugin only copies at bundle generation (generateBundle hook), not during watch rebuilds of individual chunks?
fix
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.
affects: *
deprecatedThe package is in maintenance mode with no recent updates; last release was 2.0.3 on 2019-08-19.
fix
Consider using @rollup/plugin-copy from the official rollup/plugins monorepo, which is actively maintained.
affects: *
Errors
Common errors & fixes
Error: Cannot find module 'rollup-plugin-copy-assets'
Package not installed or devDependencies not installed.
fix
Run npm install --save-dev rollup-plugin-copy-assets or yarn add --dev rollup-plugin-copy-assets.
TypeError: copy is not a function
Incorrect import: using a named import instead of default import.
fix
Use import copy from 'rollup-plugin-copy-assets' instead of import { copy } from 'rollup-plugin-copy-assets'.
Error: The 'assets' option must be an array.
Passing a single string or non-array value for the assets option.
fix
Wrap the string in an array: { assets: ['src/assets'] }.
Upgrade
Version history
2.0.3latest on npm
Audit
Dependencies
rolluprequiredpeer dependency required for plugin to work
Agent activity
11 hits · last 30 days
node
8
OpenAI (training)
2
Resources
rollup-plugin-copy-assets — npm install rollup-plugin-copy-assets · libregistry