UNPKG

@sprout2000/esbuild-copy-plugin

Version:

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

41 lines (35 loc) 2.01 kB
import $6Q1VJ$nodecrypto from "node:crypto"; import $6Q1VJ$nodefs from "node:fs"; const $788806cab0c35601$export$db1db425883506a0 = (string)=>{ const hash = (0, $6Q1VJ$nodecrypto).createHash("md5"); const data = hash.update(string, "utf-8"); return data.digest("hex"); }; const $788806cab0c35601$export$f850894d0b17ae9d = (path)=>{ if (!(0, $6Q1VJ$nodefs).existsSync(path)) return null; if ((0, $6Q1VJ$nodefs).statSync(path).isDirectory()) return null; return $788806cab0c35601$export$db1db425883506a0((0, $6Q1VJ$nodefs).readFileSync(path).toString()); }; const $788806cab0c35601$export$3dea766d36a8935f = (src, dest)=>{ if (!(0, $6Q1VJ$nodefs).existsSync(dest)) return true; if ((0, $6Q1VJ$nodefs).statSync(dest).isDirectory()) return true; return $788806cab0c35601$export$f850894d0b17ae9d(src) !== $788806cab0c35601$export$f850894d0b17ae9d(dest); }; const $788806cab0c35601$export$b979b7f816ac7b25 = (options = {})=>({ name: "esbuild-copy-plugin", setup (build) { const src = options.src || "./assets"; const dest = options.dest || "./dist"; build.onEnd(()=>// https://nodejs.org/dist/latest-v18.x/docs/api/fs.html (0, $6Q1VJ$nodefs).cpSync(src, dest, { dereference: options.dereference || false, errorOnExist: options.errorOnExist || false, filter: options.filter || $788806cab0c35601$export$3dea766d36a8935f, force: options.force || true, preserveTimestamps: options.preserveTimestamps || false, recursive: options.recursive || true, verbatimSymlinks: options.verbatimSymlinks || false })); } }); export {$788806cab0c35601$export$db1db425883506a0 as getDigest, $788806cab0c35601$export$f850894d0b17ae9d as getFileDigest, $788806cab0c35601$export$3dea766d36a8935f as filter, $788806cab0c35601$export$b979b7f816ac7b25 as copyPlugin};