rollup-plugin-cpy

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

Rollup plugin for copying files and folders using the cpy library. Version 2.0.1 is the latest stable release, last updated in 2019. Compatible with Rollup >= 1.0. Provides a simple configuration interface with glob support and verbose logging. Differentiated from other copy plugins (like rollup-plugin-copy) by leveraging the well-maintained cpy package. No active development.

error Error: Cannot find module 'cpy'
cause cpy is a peer dependency not installed automatically.
fix
Run 'npm install cpy' or add cpy to your devDependencies.
error TypeError: (0 , _rollupPluginCpy.default) is not a function
cause CommonJS require without accessing .default
fix
Use: const copy = require('rollup-plugin-cpy').default;
error Error: Unexpected token: punc (.)
cause Using ES module syntax without transpilation in Node < 9 or without type: 'module'.
fix
Use require() or transpile with Babel/TypeScript.
error ERR_PACKAGE_PATH_NOT_EXPORTED: Package subpath './package.json' is not defined
cause Old Node versions may not resolve package exports properly.
fix
Upgrade Node to >=12 or remove exports from package.json manually.
gotcha Files are copied after the bundle is written, so they may overwrite output files if dest overlaps.
fix Ensure dest directory does not overlap with output dir, or use copy as last plugin.
gotcha The cpy library uses CJS; rollup-plugin-cpy is ESM only, requiring Rollup to handle dependencies.
fix Make sure Rollup is configured to handle CJS dependencies (e.g., with @rollup/plugin-commonjs).
deprecated The cpy package v9+ changed API; this plugin uses cpy v8 internally, causing potential incompatibility if cpy is updated globally.
fix Pin cpy to v8 in your package.json if issues arise.
breaking Version 2.0.0 dropped support for Node.js < 8 and Rollup < 1.
fix Upgrade Node to >=8 and Rollup to >=1.
gotcha Glob patterns in files should use forward slashes (/) even on Windows.
fix Use path.posix.join or manually convert backslashes.
npm install rollup-plugin-cpy
yarn add rollup-plugin-cpy
pnpm add rollup-plugin-cpy

Copies all files from src/static to dist/static, excluding exclude.txt.

// Install: npm i -D rollup-plugin-cpy
// rollup.config.js
import copy from 'rollup-plugin-cpy';

export default {
  input: 'src/index.js',
  output: {
    dir: 'dist',
    format: 'cjs'
  },
  plugins: [
    copy({
      files: ['src/static/**/*', '!src/static/exclude.txt'],
      dest: 'dist/static',
      options: { verbose: true }
    })
  ]
};