JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 6
  • Score
    100M100P100Q36713F
  • License MIT

Copy files and folders, with glob support.

Package Exports

  • unplugin-copy
  • unplugin-copy/astro
  • unplugin-copy/esbuild
  • unplugin-copy/nuxt
  • unplugin-copy/rolldown
  • unplugin-copy/rollup
  • unplugin-copy/rspack
  • unplugin-copy/types
  • unplugin-copy/vite
  • unplugin-copy/webpack

Readme

unplugin-copy

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

NPM version

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

npm i unplugin-copy -D

pnpm i unplugin-copy -D

yarn i unplugin-copy -D

Install

Vite
// 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',
        },
      ],
    }),
  ],
})


Rollup
// 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',
        },
      ],
    }),
  ],
}


Webpack
// 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',
        },
      ],
    }),
  ]
}


Nuxt
// 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


Vue CLI
// 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',
          },
        ],
      }),
    ],
  },
}


esbuild
// 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',
        },
      ],
    }),
  ],
})


The code idea comes from vite-plugin-static-copy.