UNPKG

1.72 kBTypeScriptView Raw
1import type { FilterPattern } from '@rollup/pluginutils';
2import type { Plugin } from 'rollup';
3
4type Replacement = string | ((id: string) => string);
5
6export interface RollupReplaceOptions {
7 /**
8 * All other options are treated as `string: replacement` replacers,
9 * or `string: (id) => replacement` functions.
10 */
11 [str: string]:
12 | Replacement
13 | RollupReplaceOptions['include']
14 | RollupReplaceOptions['values']
15 | RollupReplaceOptions['objectGuards']
16 | RollupReplaceOptions['preventAssignment'];
17
18 /**
19 * A picomatch pattern, or array of patterns, of files that should be
20 * processed by this plugin (if omitted, all files are included by default)
21 */
22 include?: FilterPattern;
23 /**
24 * Files that should be excluded, if `include` is otherwise too permissive.
25 */
26 exclude?: FilterPattern;
27 /**
28 * If false, skips source map generation. This will improve performance.
29 * @default true
30 */
31 sourceMap?: boolean;
32 /**
33 * To replace every occurrence of `<@foo@>` instead of every occurrence
34 * of `foo`, supply delimiters
35 */
36 delimiters?: [string, string];
37 /**
38 * When replacing dot-separated object properties like `process.env.NODE_ENV`,
39 * will also replace `typeof process` object guard checks against the objects
40 * with the string `"object"`.
41 */
42 objectGuards?: boolean;
43 /**
44 * Prevents replacing strings where they are followed by a single equals
45 * sign.
46 */
47 preventAssignment?: boolean;
48 /**
49 * You can separate values to replace from other options.
50 */
51 values?: { [str: string]: Replacement };
52}
53
54/**
55 * Replace strings in files while bundling them.
56 */
57export default function replace(options?: RollupReplaceOptions): Plugin;
58
\No newline at end of file