{"id":21964,"library":"rollup-plugin-copy-assets","title":"rollup-plugin-copy-assets","description":"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.","status":"maintenance","version":"2.0.3","language":"javascript","source_language":"en","source_url":"https://github.com/bengsfort/rollup-plugin-copy-assets","tags":["javascript","rollup-plugin","bundle","copy","rollup","assets"],"install":[{"cmd":"npm install rollup-plugin-copy-assets","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-copy-assets","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-copy-assets","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency required for plugin to work","package":"rollup","optional":false}],"imports":[{"note":"CommonJS users should use const copy = require('rollup-plugin-copy-assets'); note the .default is not needed.","wrong":"const copy = require('rollup-plugin-copy-assets').default","symbol":"copy","correct":"import copy from 'rollup-plugin-copy-assets'"},{"note":"The plugin is a default export, not a named export.","wrong":"import { copy } from 'rollup-plugin-copy-assets'","symbol":"default export","correct":"import copy from 'rollup-plugin-copy-assets'"},{"note":"Since it's a default export in ESM, the CommonJS require returns the default directly.","wrong":"const copy = require('rollup-plugin-copy-assets').default;","symbol":"require (CJS)","correct":"const copy = require('rollup-plugin-copy-assets');"},{"note":"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.","wrong":null,"symbol":"TypeScript usage","correct":"import copy from 'rollup-plugin-copy-assets'"}],"quickstart":{"code":"// rollup.config.js\nimport copy from 'rollup-plugin-copy-assets';\n\nexport default {\n  input: 'src/index.js',\n  output: {\n    dir: 'dist',\n    format: 'cjs'\n  },\n  plugins: [\n    copy({\n      assets: [\n        'src/assets',\n        'src/external/buffer.bin'\n      ]\n    })\n  ]\n};","lang":"javascript","description":"Configures Rollup with the copy-assets plugin to copy a directory and a file to the output directory, preserving the relative structure."},"warnings":[{"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.","message":"v2.0.0 changed behavior: assets now overwrite existing files in output directory.","severity":"breaking","affected_versions":"<2.0.0"},{"fix":"Use absolute paths or paths relative to the project root. For glob patterns, consider rollup-plugin-copy (by rollup/plugins).","message":"The `assets` option does not support glob patterns or relative paths outside the project root (e.g., '../foo').","severity":"gotcha","affected_versions":"*"},{"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.","message":"Plugin only copies at bundle generation (generateBundle hook), not during watch rebuilds of individual chunks?","severity":"gotcha","affected_versions":"*"},{"fix":"Consider using @rollup/plugin-copy from the official rollup/plugins monorepo, which is actively maintained.","message":"The package is in maintenance mode with no recent updates; last release was 2.0.3 on 2019-08-19.","severity":"deprecated","affected_versions":"*"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Run npm install --save-dev rollup-plugin-copy-assets or yarn add --dev rollup-plugin-copy-assets.","cause":"Package not installed or devDependencies not installed.","error":"Error: Cannot find module 'rollup-plugin-copy-assets'"},{"fix":"Use import copy from 'rollup-plugin-copy-assets' instead of import { copy } from 'rollup-plugin-copy-assets'.","cause":"Incorrect import: using a named import instead of default import.","error":"TypeError: copy is not a function"},{"fix":"Wrap the string in an array: { assets: ['src/assets'] }.","cause":"Passing a single string or non-array value for the assets option.","error":"Error: The 'assets' option must be an array."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}