UNPKG

1.51 kBTypeScriptView Raw
1import rollup from 'rollup';
2import fs from 'fs-extra';
3import globby from 'globby';
4
5interface Target extends globby.GlobbyOptions {
6 /**
7 * Path or glob of what to copy.
8 */
9 readonly src: string | readonly string[];
10
11 /**
12 * One or more destinations where to copy.
13 */
14 readonly dest: string | readonly string[];
15
16 /**
17 * Change destination file or folder name.
18 */
19 readonly rename?: string | ((name: string, extension: string, fullPath: string) => string);
20
21 /**
22 * Modify file contents.
23 */
24 readonly transform?: (contents: Buffer, name: string) => any;
25}
26
27interface CopyOptions extends globby.GlobbyOptions, fs.WriteFileOptions, fs.CopyOptions {
28 /**
29 * Copy items once. Useful in watch mode.
30 * @default false
31 */
32 readonly copyOnce?: boolean;
33
34 /**
35 * Copy items synchronous.
36 * @default false
37 */
38 readonly copySync?: boolean;
39
40 /**
41 * Remove the directory structure of copied files.
42 * @default true
43 */
44 readonly flatten?: boolean;
45
46 /**
47 * Rollup hook the plugin should use.
48 * @default 'buildEnd'
49 */
50 readonly hook?: string;
51
52 /**
53 * Array of targets to copy.
54 * @default []
55 */
56 readonly targets?: readonly Target[];
57
58 /**
59 * Output copied items to console.
60 * @default false
61 */
62 readonly verbose?: boolean;
63}
64
65/**
66 * Copy files and folders using Rollup
67 */
68export default function copy(options?: CopyOptions): rollup.Plugin;