Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

esbuild-plugin-copy

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

esbuild-plugin-copy

ESBuild plugin for assets copy.

  • 2.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
136K
increased by7.95%
Maintainers
1
Weekly downloads
 
Created

What is esbuild-plugin-copy?

The esbuild-plugin-copy npm package is a plugin for esbuild that allows you to copy files and directories during the build process. This can be useful for tasks such as copying static assets, configuration files, or other resources that need to be included in the final build output.

What are esbuild-plugin-copy's main functionalities?

Copying Files

This feature allows you to copy individual files from a source directory to a destination directory during the build process. In this example, all files in the './src/assets/' directory are copied to the './dist/assets/' directory.

const esbuild = require('esbuild');
const copy = require('esbuild-plugin-copy');

esbuild.build({
  entryPoints: ['src/index.js'],
  bundle: true,
  outdir: 'dist',
  plugins: [
    copy({
      assets: {
        from: './src/assets/*',
        to: './dist/assets/'
      }
    })
  ]
}).catch(() => process.exit(1));

Copying Directories

This feature allows you to copy entire directories while preserving the directory structure. In this example, the './src/public' directory and its contents are copied to the './dist/public' directory.

const esbuild = require('esbuild');
const copy = require('esbuild-plugin-copy');

esbuild.build({
  entryPoints: ['src/index.js'],
  bundle: true,
  outdir: 'dist',
  plugins: [
    copy({
      assets: {
        from: './src/public',
        to: './dist/public',
        keepStructure: true
      }
    })
  ]
}).catch(() => process.exit(1));

Customizing Copy Behavior

This feature allows you to customize the copy behavior for different files or directories. In this example, the './src/config.json' file is copied to './dist/config.json', and all files in the './src/images/' directory are copied to './dist/images/' with the overwrite option enabled.

const esbuild = require('esbuild');
const copy = require('esbuild-plugin-copy');

esbuild.build({
  entryPoints: ['src/index.js'],
  bundle: true,
  outdir: 'dist',
  plugins: [
    copy({
      assets: [
        { from: './src/config.json', to: './dist/config.json' },
        { from: './src/images/*', to: './dist/images/', options: { overwrite: true } }
      ]
    })
  ]
}).catch(() => process.exit(1));

Other packages similar to esbuild-plugin-copy

Keywords

FAQs

Package last updated on 26 Mar 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc