webpack-assets-manifest
Version:
This Webpack plugin will generate a JSON file that matches the original filename with the hashed version.
87 lines (86 loc) • 4.33 kB
TypeScript
import { AsyncSeriesHook, SyncHook, SyncWaterfallHook } from 'tapable';
import { getSRIHash } from './helpers.js';
import { isKeyValuePair, isObject } from './type-predicate.js';
import type { AssetsStorage, AssetsStorageKey, AssetsStorageValue, JsonStringifyReplacer, JsonStringifySpace, KeyValuePair } from './types.js';
import type { Asset, Compilation, Compiler, Stats, StatsCompilation, WebpackPluginInstance } from 'webpack';
export type Options = {
assets: AssetsStorage;
contextRelativeKeys: boolean;
enabled: boolean;
entrypoints: boolean;
entrypointsKey: string | false;
entrypointsUseAssets: boolean;
extra: Record<PropertyKey, unknown>;
fileExtRegex: RegExp | false;
integrity: boolean;
integrityHashes: string[];
integrityPropertyName: string;
merge: boolean | 'customize';
output: string;
publicPath?: ((filename: string, manifest: WebpackAssetsManifest) => string) | string | boolean;
sortManifest: boolean | ((this: WebpackAssetsManifest, left: string, right: string) => number);
writeToDisk: boolean | 'auto';
replacer: JsonStringifyReplacer;
space: JsonStringifySpace;
apply?: (manifest: WebpackAssetsManifest) => void;
customize?: (entry: KeyValuePair | false | undefined | void, original: KeyValuePair, manifest: WebpackAssetsManifest, asset?: Asset) => KeyValuePair | false | undefined | void;
done?: (manifest: WebpackAssetsManifest, stats: Stats) => Promise<void>;
transform?: (assets: AssetsStorage, manifest: WebpackAssetsManifest) => AssetsStorage;
};
export declare class WebpackAssetsManifest implements WebpackPluginInstance {
#private;
options: Options;
assets: AssetsStorage;
assetNames: Map<string, string>;
compiler?: Compiler;
private currentAsset?;
hooks: Readonly<{
apply: SyncHook<[manifest: WebpackAssetsManifest], void, import("tapable").UnsetAdditionalOptions>;
customize: SyncWaterfallHook<[entry: false | void | KeyValuePair | undefined, original: KeyValuePair, manifest: WebpackAssetsManifest, asset: Asset | undefined], false | void | KeyValuePair | undefined, import("tapable").UnsetAdditionalOptions>;
transform: SyncWaterfallHook<[asset: AssetsStorage, manifest: WebpackAssetsManifest], AssetsStorage, import("tapable").UnsetAdditionalOptions>;
done: AsyncSeriesHook<[manifest: WebpackAssetsManifest, stats: Stats], import("tapable").UnsetAdditionalOptions>;
options: SyncWaterfallHook<[options: Options], Options, import("tapable").UnsetAdditionalOptions>;
afterOptions: SyncHook<[options: Options, manifest: WebpackAssetsManifest], void, import("tapable").UnsetAdditionalOptions>;
}>;
constructor(options?: Partial<Options>);
apply(compiler: Compiler): void;
get utils(): {
isKeyValuePair: typeof isKeyValuePair;
isObject: typeof isObject;
getSRIHash: typeof getSRIHash;
};
get defaultOptions(): Options;
get isMerging(): boolean;
getExtension(filename: string): string;
fixKey(key: AssetsStorageKey): AssetsStorageKey;
setRaw(key: AssetsStorageKey, value: AssetsStorageValue): this;
set(key: AssetsStorageKey, value: AssetsStorageValue): this;
has(key: AssetsStorageKey): boolean;
get(key: AssetsStorageKey, defaultValue?: AssetsStorageValue): AssetsStorageValue | undefined;
delete(key: AssetsStorageKey): boolean;
processAssetsByChunkName(assets: StatsCompilation['assetsByChunkName'], hmrFiles: Set<string>): void;
toJSON(): AssetsStorage;
toString(): string;
private maybeMerge;
private emitAssetsManifest;
private handleProcessAssetsAnalyse;
private processStatsAssets;
private getCompilationAssets;
private handleProcessAssetsReport;
private getManifestPath;
writeTo(destination: string): Promise<void>;
clear(): void;
private handleWatchRun;
shouldWriteToDisk(compilation: Compilation): boolean;
private handleAfterEmit;
private handleNormalModuleLoader;
private recordSubresourceIntegrity;
private handleCompilation;
private handleThisCompilation;
inDevServer(): boolean;
getOutputPath(): string;
getPublicPath(filename: string): string;
getProxy(raw?: boolean): this & {
[key: AssetsStorageKey]: AssetsStorageValue;
};
}