rollup-plugin-copier

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

A Rollup plugin to copy files or directories during the build process. Version 1.1.0, released under ISC license. It supports configurable hook execution (default buildEnd), optional path creation, and verbose logging. Differentiated from alternatives like rollup-plugin-copy by being actively maintained and simpler in configuration.

error Error: Could not resolve 'rollup-plugin-copier'
cause The package is not installed or not in node_modules.
fix
Run 'npm install rollup-plugin-copier' or 'yarn add rollup-plugin-copier'.
error TypeError: copier is not a function
cause Using a named import instead of default import.
fix
Change to 'import copier from 'rollup-plugin-copier''
error Error: ENOENT: no such file or directory, copyfile '...' -> '...'
cause Source file does not exist or destination directory missing and createPath not set.
fix
Check source path exists; set createPath: true for destination directories.
gotcha The plugin copies files only once during the specified hook (default buildEnd). Changes to source files after that hook will not be reflected in the output.
fix Ensure the plugin runs after all transformations; consider using buildStart or writeBundle if needed.
deprecated Option 'hookOn' is deprecated and will be removed in a future major version.
fix Stop using hookOn; the plugin will use a fixed hook in the next major.
gotcha Glob patterns in 'src' are not expanded; only exact file paths or directories work. Use a separate glob plugin if needed.
fix Use rollup-plugin-copy-glob or pre-expand globs before passing to copier.
npm install rollup-plugin-copier
yarn add rollup-plugin-copier
pnpm add rollup-plugin-copier

Configures rollup-plugin-copier to copy a single file and a glob pattern, with path creation enabled.

// rollup.config.js
import copier from 'rollup-plugin-copier';

export default {
  input: 'src/index.js',
  output: { dir: 'dist', format: 'esm' },
  plugins: [
    copier({
      items: [
        { src: 'public/robots.txt', dest: 'dist/robots.txt' },
        { src: 'assets/*', dest: 'dist/assets', createPath: true }
      ],
      verbose: true
    })
  ]
};