Skip to content

An esbuild plugin to copy static files that changed from a source directory to a destination directory.

License

Notifications You must be signed in to change notification settings

sprout2000/esbuild-copy-plugin

Repository files navigation

@sprout2000/esbuild-copy-plugin

jest GitHub top language npm

An esbuild plugin to copy static files from a source directory to a destination directory.

* This plugin is a typed and fully tested version of @nickjj's esbuild-copy-static-files.

Installation

npm install --save-dev @sprout2000/esbuild-copy-plugin

You will need to have Node.js >=16.7 installed.

Usage

import { build } from "esbuild";
import { copyPlugin } from "@sprout2000/esbuild-copy-plugin";

build({
  plugins: [
    copyPlugin({
      src: "./assets/icon.png",
      dest: "./dist/logo.png",
    }),
  ],
});

API

interface CopyPluginOptions extends fs.CopySyncOptions {
  src?: string;
  dest?: string;
}
option default
src?: string "assets"
dest?: string "dist"
dereference?: boolean false
errorOnExist?: boolean false
filter?: (src, dest) => boolean undefined
force?: boolean false
preserveTimestamps?: boolean false
recursive?: boolean true
verbatimSymlinks?: boolean false

See fs.CopySyncOptions in Node.js LTS for more details.

Unit test

# clone this repo, and install devDependencies...
git clone https://github.com/sprout2000/esbuild-copy-plugin.git
cd esbuild-copy-plugin
npm install

# run the test
npm test

About

An esbuild plugin to copy static files that changed from a source directory to a destination directory.

Topics

Resources

License

Stars

Watchers

Forks