mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-05 07:17:04 +00:00
Merge pull request #31441 from stephtr/webpack-manifest-plugin
update webpack-manifest-plugin
This commit is contained in:
+28
-15
@@ -1,4 +1,4 @@
|
||||
// Type definitions for webpack-manifest-plugin 1.3
|
||||
// Type definitions for webpack-manifest-plugin 2.0
|
||||
// Project: https://github.com/danethurber/webpack-manifest-plugin
|
||||
// Definitions by: Andrew Makarov <https://github.com/r3nya>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
@@ -19,13 +19,16 @@ declare namespace WebpackManifestPlugin {
|
||||
[propName: string]: any;
|
||||
}
|
||||
|
||||
interface HooksOptions {
|
||||
interface FileDescriptor {
|
||||
path: string;
|
||||
chunk: Chunk;
|
||||
name: string | null;
|
||||
isChunk: boolean;
|
||||
/** Is required to run you app. Cannot be true if isChunk is false. */
|
||||
isInitial: boolean;
|
||||
isChunk: boolean;
|
||||
/** Only available is isChunk is true. */
|
||||
chunk?: Chunk;
|
||||
isAsset: boolean;
|
||||
/** Is required by a module. Cannot be true if isAsset is false. */
|
||||
isModuleAsset: boolean;
|
||||
}
|
||||
|
||||
@@ -37,15 +40,16 @@ declare namespace WebpackManifestPlugin {
|
||||
fileName?: string;
|
||||
|
||||
/**
|
||||
* A path prefix for all file references. Useful for including your output path in the manifest.
|
||||
*/
|
||||
basePath?: string;
|
||||
|
||||
/**
|
||||
* A path prefix used only on output files, similar to Webpack's output.publicPath. Ignored if basePath was also provided.
|
||||
* A path prefix that will be added to values of the manifest.
|
||||
* Default: output.publicPath
|
||||
*/
|
||||
publicPath?: string;
|
||||
|
||||
/**
|
||||
* A path prefix for all keys. Useful for including your output path in the manifest.
|
||||
*/
|
||||
basePath?: string;
|
||||
|
||||
/**
|
||||
* If set to true will emit to build folder and memory in combination with webpack-dev-server
|
||||
* Default: false
|
||||
@@ -63,17 +67,26 @@ declare namespace WebpackManifestPlugin {
|
||||
/**
|
||||
* Filter out files.
|
||||
*/
|
||||
filter?: (options: HooksOptions) => void;
|
||||
filter?: (file: FileDescriptor) => boolean;
|
||||
|
||||
/**
|
||||
* Modify files details before the manifest is created.
|
||||
*/
|
||||
map?: (options: HooksOptions) => void;
|
||||
map?: (file: FileDescriptor) => FileDescriptor;
|
||||
|
||||
/**
|
||||
* Create the manifest. It can return anything as long as it's serialisable by JSON.stringify. Use the seed options to populate manifest.
|
||||
* Default: (manifest, {name, path}) => ({...manifest, [name]: path})
|
||||
* Sort files before they are passed to generate.
|
||||
*/
|
||||
reduce?: (manifest: any, options: HooksOptions) => void;
|
||||
sort?: (a: FileDescriptor, b: FileDescriptor) => number;
|
||||
|
||||
/**
|
||||
* Create the manifest. It can return anything as long as it's serialisable by JSON.stringify.
|
||||
*/
|
||||
generate?: (seed: object, files: FileDescriptor[]) => object;
|
||||
|
||||
/**
|
||||
* Output manifest file in different format then json (i.e. yaml).
|
||||
*/
|
||||
serialize?: (manifest: object) => string;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,14 +14,12 @@ const options: WebpackManifestPlugin.Options = {
|
||||
map: (file) => {
|
||||
if (file.name) {
|
||||
file.name = path.join(path.dirname(file.path), file.name);
|
||||
return file;
|
||||
}
|
||||
},
|
||||
reduce: (manifest, { name, path }) => {
|
||||
if (name) {
|
||||
return { ...manifest, [name]: path };
|
||||
}
|
||||
return file;
|
||||
},
|
||||
sort: (a, b) => a.path.localeCompare(b.path),
|
||||
generate: (seed, files) => files.reduce((manifest, {name, path}) => name ? {...manifest, [name]: path} : manifest, seed),
|
||||
serialize: (manifest) => JSON.stringify(manifest, null, 2)
|
||||
};
|
||||
|
||||
const c: Configuration = {
|
||||
|
||||
Reference in New Issue
Block a user