update definition, add tests

This commit is contained in:
Stephan Troyer
2018-12-16 13:04:33 +01:00
parent a294b4765e
commit cd4954e1f4
2 changed files with 5 additions and 7 deletions
+1 -1
View File
@@ -77,7 +77,7 @@ declare namespace WebpackManifestPlugin {
/**
* Sort files before they are passed to generate.
*/
sort?: (file: FileDescriptor) => number;
sort?: (a: FileDescriptor, b: FileDescriptor) => number;
/**
* Create the manifest. It can return anything as long as it's serialisable by JSON.stringify.
@@ -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 = {