@farmfe/js-plugin-copy
JavaScript plugin that copies files or globs at the end of a Farm build.
Installation
javascript
npm install @farmfe/js-plugin-copy --save-devjavascript
yarn add @farmfe/js-plugin-copy --devjavascript
pnpm add @farmfe/js-plugin-copy --save-devUsage
ts
import { defineConfig } from "@farmfe/core";
import copy from "@farmfe/js-plugin-copy";
export default defineConfig({
plugins: [
copy({
targets: [
{ src: "public/**/*", dest: "dist" },
],
verbose: true,
}),
],
});
Options
targets?: Target[]— copy targets. Defaults to[].copyOnce?: boolean— copy only once, useful in watch mode. Defaults tofalse.copySync?: boolean— use synchronous copy operations. Defaults tofalse.flatten?: boolean— remove source directory structure underdest. Defaults totrue.verbose?: boolean— log copied files. Defaults tofalse.
Each target supports:
src: string | string[]— path or glob to copy.dest: string | string[]— destination directory or directories.rename?: string | ((name: string, extension: string, fullPath: string) => string)— rename copied files.transform?: (contents: Buffer, name: string) => string | Buffer | Uint8Array— replace file contents before writing. The implementation only allowstransformfor matched files; if a glob matches a directory, usingtransformthrows because directories do not have file contents to rewrite.
Other plugin and target options are passed through to globby; remaining plugin options are also passed to fs-extra copy/write calls.
Farm