Registry / devops / copy-vite-plugin

copy-vite-plugin

JSON →
library1.0.1jsnpmunverified

A Vite plugin for copying files and directories during build, designed as a drop-in replacement for copy-webpack-plugin for projects migrating from webpack to Vite. Current version 1.0.1 (stable). It offers a simple API similar to copy-webpack-plugin, supporting glob patterns and multiple source destinations. Unlike alternatives like vite-plugin-static-copy, it aims for minimal configuration and direct compatibility with webpack's pattern syntax.

npm install copy-vite-plugin
INSTALL
IMPORT
SIG · COPY-VITE-PLUGIN
C
copy-vite-plugin
devopsjavascriptv1.0.1
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 'copy-vite-plugin'
import copy from 'copy-vite-plugin'
The main export is a named export 'copy', not a default export. Also works with require: const { copy } = require('copy-vite-plugin')
CopyOptions
import type { CopyOptions } from 'copy-vite-plugin'
import { CopyOptions } from 'copy-vite-plugin'
Type import is optional; functional plugin does not require types at runtime.
Pattern
import type { Pattern } from 'copy-vite-plugin'
TypeScript type for pattern objects; can be used to type array elements.

Basic setup: copies a directory and a file from source to output during build.

import { defineConfig } from 'vite'; import { copy } from 'copy-vite-plugin'; export default defineConfig({ plugins: [ copy({ pattern: [ { from: 'src/images', to: 'images' }, { from: 'public/favicon.ico', to: 'favicon.ico' }, ], }), ], });
Debug
Known issues
gotchaThe 'pattern' key is singular; using 'patterns' (as in copy-webpack-plugin) will silently be ignored.
fix
Use 'pattern' instead of 'patterns' in the options object.
affects: >=1.0.0
gotchaRelative paths in 'from' and 'to' are resolved relative to the project root (process.cwd()), not the config file location.
fix
Use absolute paths or paths relative to project root.
affects: >=1.0.0
gotchaPlugin only runs during build (not dev server) by default; files copied are not watched.
fix
Use 'vite-plugin-static-copy' if you need copy during dev with HMR.
affects: >=1.0.0
deprecatedThe 'context' option from copy-webpack-plugin is not supported; use absolute paths instead.
fix
Use full paths or rely on root-relative paths.
affects: >=1.0.0
gotchaGlob patterns in 'from' are not supported; use exact file or directory paths.
fix
Specify exact paths or use another plugin like 'vite-plugin-static-copy' that supports globs.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: copy is not a function
Importing using default import instead of named import.
fix
Use 'import { copy } from 'copy-vite-plugin' instead of 'import copy from 'copy-vite-plugin'.
Pattern is not iterable
Options object has 'patterns' key instead of 'pattern'.
fix
Rename 'patterns' to 'pattern' in the plugin options.
ENOENT: no such file or directory, copyfile '...' -> '...'
The source file or directory does not exist, or path is relative and resolved incorrectly.
fix
Ensure paths are relative to project root or use absolute paths.
Upgrade
Version history
1.0.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
14 hits · last 30 days
node
12
Resources
copy-vite-plugin — npm install copy-vite-plugin · libregistry