Code Monkey home page Code Monkey logo

esbuild-copy-plugin's Introduction

@sprout2000/esbuild-copy-plugin

jest GitHub top language npm

An esbuild plugin to to efficiently 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

esbuild-copy-plugin's People

Contributors

dependabot[bot] avatar sprout2000 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

esbuild-copy-plugin's Issues

Import instructions don't appear to work on node 19.4

When I import { copyPlugin } from '@sprout2000/esbuild-copy-plugin'; as per the README, I get

import { copyPlugin } from '@sprout2000/esbuild-copy-plugin';
         ^^^^^^^^^^
SyntaxError: Named export 'copyPlugin' not found. The requested module '@sprout2000/esbuild-copy-plugin' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from '@sprout2000/esbuild-copy-plugin';
const { copyPlugin } = pkg;

The second form does indeed work as suggested. This is in a script executed via node esbuild.config.js which is defined as "type": "module" in package.json. Is there something I'm failing to do?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.