Skip to content

Commit

Permalink
webpack-manifest-plugin: Update for 3.0
Browse files Browse the repository at this point in the history
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
  • Loading branch information
andersk committed Dec 10, 2020
1 parent d40fa85 commit e86d93d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
31 changes: 25 additions & 6 deletions types/webpack-manifest-plugin/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
// Type definitions for webpack-manifest-plugin 2.1
// Type definitions for webpack-manifest-plugin 3.0
// Project: https://github.com/danethurber/webpack-manifest-plugin
// Definitions by: Andrew Makarov <https://github.com/r3nya>, Jeremy Monson <https://github.com/monsonjeremy>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3

import { Plugin } from 'webpack';
import { SyncWaterfallHook } from 'tapable';
import { Compiler, WebpackPluginInstance } from 'webpack';

export = WebpackManifestPlugin;

declare class WebpackManifestPlugin extends Plugin {
export class WebpackManifestPlugin implements WebpackPluginInstance {
constructor(options?: WebpackManifestPlugin.Options);
apply(compiler: Compiler): void;
}

declare namespace WebpackManifestPlugin {
export namespace WebpackManifestPlugin {
interface Chunk {
id: string;
parents: string[];
Expand Down Expand Up @@ -88,5 +88,24 @@ declare namespace WebpackManifestPlugin {
* Output manifest file in different format then json (i.e. yaml).
*/
serialize?: (manifest: object) => string;

/**
* Remove hashes from manifest keys.
* Default: /([a-f0-9]{32}\.?)/gi
*/
removeKeyHash?: RegExp | false;

/**
* Use the keys specified in the entry property as keys in the manifest.
* Default: false
*/
useEntryKeys?: boolean;
}
}

export function getCompilerHooks(
compiler: Compiler,
): {
afterEmit: SyncWaterfallHook;
beforeEmit: SyncWaterfallHook;
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Configuration } from 'webpack';
import path = require('path');
import WebpackManifestPlugin = require('webpack-manifest-plugin');
import { WebpackManifestPlugin } from 'webpack-manifest-plugin';

const options: WebpackManifestPlugin.Options = {
fileName: 'manifest.json',
Expand All @@ -21,6 +21,8 @@ const options: WebpackManifestPlugin.Options = {
generate: (seed, files) =>
files.reduce((manifest, { name, path }) => (name ? { ...manifest, [name]: path } : manifest), seed),
serialize: manifest => JSON.stringify(manifest, null, 2),
removeKeyHash: false,
useEntryKeys: true,
};

const c: Configuration = {
Expand Down

0 comments on commit e86d93d

Please sign in to comment.