From 558db7462335794b1931b5fc0ae6207a323d5afa Mon Sep 17 00:00:00 2001 From: Andrew Makarov Date: Thu, 16 Nov 2017 23:19:45 +0300 Subject: [PATCH] updated typings and test file --- types/webpack-manifest-plugin/index.d.ts | 21 ++++++---------- .../webpack-manifest-plugin-tests.ts | 25 ++++++++++++++++++- 2 files changed, 32 insertions(+), 14 deletions(-) diff --git a/types/webpack-manifest-plugin/index.d.ts b/types/webpack-manifest-plugin/index.d.ts index 736bcedef7..6c90731424 100644 --- a/types/webpack-manifest-plugin/index.d.ts +++ b/types/webpack-manifest-plugin/index.d.ts @@ -20,13 +20,13 @@ declare namespace WebpackManifestPlugin { } interface HooksOptions { - path?: string; - chunk?: Chunk; - name?: string; - isChunk?: boolean; - isInitial?: boolean; - isAsset?: boolean; - isModuleAsset?: boolean; + path: string; + chunk: Chunk; + name: string | null; + isChunk: boolean; + isInitial: boolean; + isAsset: boolean; + isModuleAsset: boolean; } interface Options { @@ -46,11 +46,6 @@ declare namespace WebpackManifestPlugin { */ publicPath?: string; - /** - * Removes unwanted strings from source filenames. - */ - stripSrc?: string | RegExp; - /** * If set to true will emit to build folder and memory in combination with webpack-dev-server * Default: false @@ -79,6 +74,6 @@ declare namespace WebpackManifestPlugin { * 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}) */ - reduce?: (options: HooksOptions) => void; + reduce?: (manifest: any, options: HooksOptions) => void; } } diff --git a/types/webpack-manifest-plugin/webpack-manifest-plugin-tests.ts b/types/webpack-manifest-plugin/webpack-manifest-plugin-tests.ts index aae6739a4d..134e6825e6 100644 --- a/types/webpack-manifest-plugin/webpack-manifest-plugin-tests.ts +++ b/types/webpack-manifest-plugin/webpack-manifest-plugin-tests.ts @@ -1,5 +1,28 @@ import { Configuration } from 'webpack'; -import * as WebpackManifestPlugin from 'webpack-manifest-plugin'; +import path = require('path'); +import WebpackManifestPlugin = require('webpack-manifest-plugin'); + +const options: WebpackManifestPlugin.Options = { + filename: 'manifest.json', + basePath: '/src/', + seed: { + name: 'Hello world', + }, + publicPath: 'prod', + writeToFileEmit: false, + filter: (file) => file.isInitial, + 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 }; + } + }, +}; const c: Configuration = { plugins: [