UNPKG

2.73 kBTypeScriptView Raw
1import { SyncWaterfallHook } from "tapable";
2import { Chunk, Compiler, WebpackPluginInstance } from "webpack";
3
4export const WebpackManifestPlugin: {
5 new(options?: Options): WebpackPluginInstance;
6};
7
8export interface FileDescriptor {
9 /** Only available if isChunk is true. */
10 chunk?: Chunk | undefined;
11 isAsset: boolean;
12 isChunk: boolean;
13 /** Is required to run you app. Cannot be true if isChunk is false. */
14 isInitial: boolean;
15 /** Is required by a module. Cannot be true if isAsset is false. */
16 isModuleAsset: boolean;
17 name: string | null;
18 path: string;
19}
20
21export interface Options {
22 /**
23 * A path prefix for all keys. Useful for including your output path in the manifest.
24 * Default: ''
25 */
26 basePath?: string | undefined;
27
28 /**
29 * The manifest filename in your output directory.
30 * Default: 'manifest.json'
31 */
32 fileName?: string | undefined;
33
34 /**
35 * Filter out files which make up the manifest. Return true to keep the file, false to remove it.
36 */
37 filter?: ((file: FileDescriptor) => boolean) | undefined;
38
39 /**
40 * Create the manifest. It can return anything as long as it's serializable by JSON.stringify.
41 */
42 generate?: ((seed: object, files: FileDescriptor[], entries: Record<string, string[]>) => object) | undefined;
43
44 /**
45 * Modify file details before the manifest is created.
46 */
47 map?: ((file: FileDescriptor) => FileDescriptor) | undefined;
48
49 /**
50 * A path prefix that will be added to values of the manifest.
51 * Default: output.publicPath
52 */
53 publicPath?: string | undefined;
54
55 /**
56 * Remove hashes from manifest keys. Defaults to Webpack's md5 hash.
57 * Default: /([a-f0-9]{32}\.?)/gi
58 */
59 removeKeyHash?: RegExp | boolean | undefined;
60
61 /**
62 * A cache of key/value pairs to used to seed the manifest.
63 * Default: {}
64 */
65 seed?: object | undefined;
66
67 /**
68 * Output manifest file in different format then json (i.e. yaml).
69 */
70 serialize?: ((manifest: object) => string) | undefined;
71
72 /**
73 * Sort files before they are passed to generate.
74 */
75 sort?: ((fileA: FileDescriptor, fileB: FileDescriptor) => number) | undefined;
76
77 /**
78 * If true, the keys specified in the entry property will be used as keys in the manifest.
79 * Default: false
80 */
81 useEntryKeys?: boolean | undefined;
82
83 /**
84 * If set to true will emit to build folder and memory in combination with webpack-dev-server.
85 * Default: false
86 */
87 writeToFileEmit?: boolean | undefined;
88}
89
90export function getCompilerHooks(compiler: Compiler): { afterEmit: SyncWaterfallHook; beforeEmit: SyncWaterfallHook };
91
\No newline at end of file