rollup-copy-plugin
raw JSON → 0.1.0 verified Mon Apr 27 auth: no javascript maintenance
A simple Rollup plugin that copies files from source to destination during the build process. Version 0.1.0 is the initial and only release. It copies files once when Rollup starts; subsequent changes are not watched. This is a minimal plugin for static file copying, in contrast to more feature-rich alternatives like rollup-plugin-copy that support glob patterns and watch mode. It is designed for simple use cases where files need to be placed in the output directory without transformation.
Common errors
error Error: Cannot find module 'rollup-copy-plugin' ↓
cause Package is not installed.
fix
Run 'npm install rollup-copy-plugin --save-dev'
error TypeError: copyPlugin is not a function ↓
cause Incorrect import (e.g., named import instead of default).
fix
Use 'import copyPlugin from 'rollup-copy-plugin''
error Error: ENOENT: no such file or directory, copyfile '/src/test1.txt' -> '/dist/test1.txt' ↓
cause Source file does not exist or path is incorrect.
fix
Check that the source path is correct relative to the Rollup config file's working directory.
Warnings
gotcha Files are copied only once when Rollup starts. Changes made after initial build are not reflected unless Rollup is restarted. ↓
fix Restart Rollup to re-copy files, or use a plugin with watch mode like rollup-plugin-copy.
gotcha The plugin does not support glob patterns; paths must be explicit. ↓
fix Use explicit file paths or switch to rollup-plugin-copy for glob support.
gotcha If the output directory does not exist, the plugin may fail silently depending on the environment. ↓
fix Ensure output directories exist or use a plugin that creates directories automatically.
Install
npm install rollup-copy-plugin yarn add rollup-copy-plugin pnpm add rollup-copy-plugin Imports
- default wrong
const copyPlugin = require('rollup-copy-plugin')correctimport copyPlugin from 'rollup-copy-plugin' - default
const copyPlugin = require('rollup-copy-plugin') - copyPlugin
import copyPlugin from 'rollup-copy-plugin'
Quickstart
// rollup.config.js
import copyPlugin from 'rollup-copy-plugin'
export default {
input: 'src/index.js',
output: {
dir: 'dist',
format: 'es'
},
plugins: [
copyPlugin({
'./src/static/data.json': './dist/data.json',
'./src/assets/logo.png': './dist/assets/logo.png'
})
]
}