updated typings and test file

This commit is contained in:
Andrew Makarov
2017-11-16 23:19:45 +03:00
parent 21a6375a99
commit 558db74623
2 changed files with 32 additions and 14 deletions
+8 -13
View File
@@ -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;
}
}
@@ -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: [