Registry / devops / rollup-plugin-copy2

rollup-plugin-copy2

JSON →
library0.4.0jsnpmunverified

A Rollup plugin to copy additional assets to the build directory, version 0.4.0. Unlike typical copy plugins, it does not copy by default but emits files into the Rollup bundle, making them accessible to other plugins (e.g., rollup-plugin-zip). Actual copying is handled by Rollup itself. It supports glob patterns, source-destination pairs, and an optional outputDirectory for direct disk writes. Requires Rollup >=3.20.0. Minimalistic, ESM-only, with TypeScript support.

npm install rollup-plugin-copy2
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-COPY
R
rollup-plugin-copy2
devopsjavascriptv0.4.0
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-copy2'
import copy from 'rollup-plugin-copy2'
Named export, not default. ESM-only; no CommonJS support.
copy
const { copy } = await import('rollup-plugin-copy2')
const { copy } = require('rollup-plugin-copy2')
ESM dynamic import works, but require() fails because package is ESM-only.
CopyOptions
import type { CopyOptions } from 'rollup-plugin-copy2'
TypeScript users can import the CopyOptions type for type safety.

Rollup configuration using copy plugin with glob, source-destination pair, and extra output directory.

// rollup.config.js import { copy } from 'rollup-plugin-copy2' export default { input: 'src/index.js', output: { dir: 'dist', format: 'es', }, plugins: [ copy({ assets: [ 'README.md', ['src/data.txt', 'assets/data.txt'], 'node_modules/some-lib/*.css', ], notEmitFiles: false, outputDirectory: 'additional', }), ], }
Debug
Known issues
gotchaFiles are not physically copied by default; they are emitted into Rollup's bundle. Use outputDirectory option to write them to disk.
fix
Set outputDirectory to a path if you need files on disk, or use another plugin like rollup-plugin-copy (note different package).
affects: >=0.1.0
gotchaGlob patterns only work when source is a single string, not in [source, dest] tuples. Tuples expect exact file paths.
fix
Use single string glob for multiple files; for renaming, use [exactPath, destPath].
affects: >=0.1.0
deprecatedThe plugin is ESM-only and does not support require(). Using require() will throw an error.
fix
Use import or dynamic import() in an ESM context. Set type: 'module' in package.json or use .mjs extension.
affects: >=0.1.0
gotchaFiles emitted by this plugin are not automatically included in the output unless downstream plugins handle them. If you only use copy without zip, you may see no output files.
fix
Either set outputDirectory to copy to disk, or add another plugin that consumes emitted assets (e.g., rollup-plugin-zip).
affects: >=0.1.0
Errors
Common errors & fixes
The requested module 'rollup-plugin-copy2' does not provide an export named 'default'
Attempting default import instead of named import.
fix
Change import copy from 'rollup-plugin-copy2' to import { copy } from 'rollup-plugin-copy2'.
Error: rollup-plugin-copy2 requires Rollup >=3.20.0
Installed rollup version is too old.
fix
Upgrade rollup to ^3.20.0 or later: npm install rollup@latest --save-dev.
TypeError: copy is not a function
Importing the wrong export (e.g., import * as copy from '...' then using copy()).
fix
Use named import: import { copy } from 'rollup-plugin-copy2'.
Upgrade
Version history
0.4.0latest on npm
Audit
Dependencies
rolluprequiredpeer dependency: requires Rollup >=3.20.0 for plugin hooks
Agent activity
7 hits · last 30 days
node
6
Resources
rollup-plugin-copy2 — npm install rollup-plugin-copy2 · libregistry