UNPKG

@planjs/webpack-deploy-plugin

Version:

The webpack plugin handles various uploads of front-end files

89 lines (88 loc) 2.5 kB
import type { Compiler, Stats } from "webpack"; import { OSSUploadOptions } from "oss-upload-tool"; import shell from "shelljs"; import type { ExecOptions } from "shelljs"; export declare type TargetItem = { type?: "rsync" | "oss"; /** * Upload file to directory */ dest: string; /** * Match which files can be uploaded * eg: HOMEDIR/project/dist/bundle.js * upload **\/bundle.js * filter !**\/bundle.js * @see https://github.com/sindresorhus/multimatch */ patterns?: string | string[]; /** * @see https://linux.die.net/man/1/rsync */ rsyncOptions?: { /** * Rsync args * @see https://github.com/mattijs/node-rsync * eg: ['bwlimit', 10] */ args?: [string, string?][]; }; OSSUploadOptions?: OSSUploadOptions; /** * Maximum number of failed retries * @default 0 */ maxAttempts?: number; /** * Execution timeout */ timeout?: number; /** * Executed when upload starts * cwd: webpack work dir */ execUploadStartScripts?: string[][] | string[]; /** * Executed when upload finish * cwd: webpack work dir */ execUploadFinishScripts?: string[][] | string[]; /** * before upload callback */ onUploadStart?: (stats: Stats, shelljs: typeof shell) => void | Promise<void>; /** * Upload finish callback */ onUploadFinish?: (stats: Stats, shelljs: typeof shell) => void | Promise<void>; /** * @link {require("shelljs").ExecOptions} */ execOptions?: ExecOptions; /** * Whether to upload the output directory completely * @default false `compilation.assets` */ isUploadOutputDir?: boolean; }; export declare type WebpackDeployPluginOptions = { /** * Upload related configuration * If configured as an object, the key is the environment, and the value is the upload configuration */ targets: Record<any, TargetItem> | TargetItem; /** * If there are multiple configurations, it is the key of the corresponding environment */ env?: string; }; declare class WebpackDeployPlugin { name: string; options: WebpackDeployPluginOptions; private canDeploy; constructor(options: WebpackDeployPluginOptions); apply: (compiler: Compiler) => void; get target(): TargetItem; } declare const _default: typeof WebpackDeployPlugin; export default _default;