# unplugin-copy

> Copy files and folders, with glob support.

Latest version **4.0.1** (published 2025-05-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install unplugin-copy
pnpm add unplugin-copy
yarn add unplugin-copy
bun add unplugin-copy
```

## Health

**Score 45/100 (D)** — status: maintenance-mode.

Positive: has types; esm support; no vulnerabilities; has provenance; high quality score.

Warnings: low downloads.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.0.1 |
| Published | 2025-05-29 |
| First published | 2023-06-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 5 |
| Unpacked size | 29.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 2 |
| Maintainers | xiankq |
| Keywords | unplugin, vite, webpack, rollup, rolldown, rspack, farm, transform, copy, moveFiles |

## Links

- npm: https://www.npmjs.com/package/unplugin-copy
- Repository: https://github.com/xiankq/unplugin-copy
- Homepage: https://github.com/xiankq/unplugin-copy#readme
- Issues: https://github.com/xiankq/unplugin-copy/issues
- npm.io page: https://npm.io/package/unplugin-copy

## Dependencies (5)

- [fs-extra](https://npm.io/package/fs-extra.md) ^11.3.0
- [unplugin](https://npm.io/package/unplugin.md) ^2.3.5
- [fast-glob](https://npm.io/package/fast-glob.md) ^3.3.3
- [serve-static](https://npm.io/package/serve-static.md) ^2.2.0
- [@types/fs-extra](https://npm.io/package/@types/fs-extra.md) ^11.0.4

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 4.0.1 (latest) — 2025-05-29
- 4.0.0 — 2025-05-29
- 3.0.1 — 2025-05-26
- 3.0.0 — 2025-05-26
- 2.1.0 — 2025-01-21
- 2.0.0 — 2024-12-13
- 1.0.1 — 2024-10-10
- 1.0.0 — 2024-10-10
- 0.1.9 — 2024-10-09
- 0.1.8 — 2024-10-09
- 0.1.4 — 2024-08-12
- 0.1.3 — 2024-07-26
- 0.1.2 — 2023-06-26
- 0.1.1 — 2023-06-25
- 0.1.0 — 2023-06-25

## README

# unplugin-copy

Replace variables in code with other values or expressions. Supports Vite, Rollup, Webpack, Rspack and more.

[![NPM version](https://img.shields.io/npm/v/unplugin-copy?color=a1b858&label=)](https://www.npmjs.com/package/unplugin-copy)

##### NOTE

The original intention of this plugin is to provide compatibility for lower-level plugins. You should give priority to using the `copy` that comes with the build tool.

## Features

- Support Vite, Webpack, Vue CLI, Rollup, esbuild and more, powered by unplugin.
- In the Vite development environment, path mapping is used instead of real copying.

## Install

```bash
npm i unplugin-copy -D

pnpm i unplugin-copy -D

yarn i unplugin-copy -D
```

## Install

<details>
<summary>Vite</summary><br>

```ts
// vite.config.ts
import unpluginCopy from 'unplugin-copy/vite'

export default defineConfig({
  plugins: [
    unpluginCopy({
      targets: [
        // http://localhost:5173/vue/index.js => node_modules/vue/index.js
        {
          src: 'node_modules/vue/**',
          dest: 'vue',
        },
      ],
    }),
  ],
})
```

<br></details>

<details>
<summary>Rollup</summary><br>

```ts
// rollup.config.js
import unpluginCopy from 'unplugin-copy/rollup'

export default {
  plugins: [
    unpluginCopy({
      targets: [
        // http://localhost:5173/vue/index.js => node_modules/vue/index.js
        {
          src: 'node_modules/vue/**',
          dest: 'vue',
        },
      ],
    }),
  ],
}
```

<br></details>

<details>
<summary>Webpack</summary><br>

```ts
// webpack.config.js
module.exports = {
  /* ... */
  plugins: [
    unpluginCopy({
      targets: [
        // http://localhost:5173/vue/index.js => node_modules/vue/index.js
        {
          src: 'node_modules/vue/**',
          dest: 'vue',
        },
      ],
    }),
  ]
}
```

<br></details>

<details>
<summary>Nuxt</summary><br>

```ts
// nuxt.config.js
export default {
  buildModules: [
    ['unplugin-copy/nuxt', {
      targets: [
        // http://localhost:5173/vue/index.js => node_modules/vue/index.js
        {
          src: 'node_modules/vue/**',
          dest: 'vue',
        },
      ],
    }],
  ],
}
```

> This module works for both Nuxt 2 and [Nuxt Vite](https://github.com/nuxt/vite)

<br></details>

<details>
<summary>Vue CLI</summary><br>

```ts
// vue.config.js
module.exports = {
  configureWebpack: {
    plugins: [
      require('unplugin-copy/webpack')({
        targets: [
        // http://localhost:5173/vue/index.js => node_modules/vue/index.js
          {
            src: 'node_modules/vue/**',
            dest: 'vue',
          },
        ],
      }),
    ],
  },
}
```

<br></details>

<details>
<summary>esbuild</summary><br>

```ts
// esbuild.config.js
import { build } from 'esbuild'
import unpluginCopy from 'unplugin-copy/esbuild'

build({
  plugins: [
    unpluginCopy({
      targets: [
        // http://localhost:5173/vue/index.js => node_modules/vue/index.js
        {
          src: 'node_modules/vue/**',
          dest: 'vue',
        },
      ],
    }),
  ],
})
```

<br></details>

The code idea comes from [vite-plugin-static-copy](https://github.com/sapphi-red/vite-plugin-static-copy).

---
_Source: https://npm.io/package/unplugin-copy · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
