import { type Compiler } from 'webpack'; export interface CopyPattern { /** 来源地址 */ from: string; /** 目标地址 */ to: string; } type DirSpec = { kind: 'plain'; scanRoot: string; } | { kind: 'pattern'; scanRoot: string; toPrefix: string; }; /** 需要拷贝的文件列表 * @example * ```ts * export default { * copy: { * // 将 public 下的 a.json 和 s.txt 添加到资源, 并将 public3/a.json 添加到资源, 目标地址为 public4/a.json * files: ['public/a.json', 'public/s.txt', { from: 'public3/a.json', to: 'public4/a.json' }], * // 将 static 文件夹添加到资源, 并将 abv/static2 文件夹添加到到资源, 目标地址为 ccs/public2 * dirs: ['static', { from: 'abv/static2', to: 'ccs/public2' }] * } * } * ``` */ export interface CopyPluginOption { /** 需要拷贝的文件列表 */ files?: (string | CopyPattern)[]; /** 需要拷贝的文件夹 */ dirs?: (string | CopyPattern)[]; } /** * 与 {@link CopyPlugin} 当前配置下会 emit 的资源名一致,供 `SourceMapDevToolPlugin` 的 `exclude` 等使用。 * 在构建配置阶段计算一次,避免在编译管线中反复改写资源。 */ export declare function collectCopyDestAssetNames(opt: CopyPluginOption): Set; export declare class CopyPlugin { private readonly fileEntries; private readonly dirSpecs; /** 上一轮已发出的资源路径(dest),用于删除检测 */ private cacheDests; /** 当前配置下 dest → 源路径,用于在资源被移除时清理 mtime 缓存 */ private destToSrc; private fileTimestamps; constructor(option: CopyPluginOption); private getFiles; private hasFileChanged; apply(compiler: Compiler): void; } export { };