UNPKG

@invisit/webpack-aws-lambda-auto-deploy-plugin

Version:

Uploads compiled assets to s3 after build

75 lines (74 loc) 2.35 kB
import type AWS from "aws-sdk"; export declare const KeyTemplateDefault = "{{entry}}-{{timestamp}}"; export declare type AutoDeployStorage = "lambda" | "s3"; /** * Map outputs to lambda function names */ export interface EntryMapping { /** * If `fn` is not a valid lambda name ref * then code updates will not occur */ fn?: string[]; entry: string; } export declare type ErrorKind = Error | { message: string; stack: string; code?: string | number; } | string | undefined; export interface AWSDeployEvent<Storage extends AutoDeployStorage> { phase: "archive" | "upload" | "update" | "complete"; message?: string; timestamp: Date; region: string; functionNames: string[]; uploadedUrl?: string; archiveFile: string; archiveSize: number; storage: AWSDeployStorageConfig<Storage>; error?: ErrorKind; } export declare type AWSDeployStorageConfig<Storage extends AutoDeployStorage> = { type: Storage; } & (Storage extends "s3" ? { bucket: string; /** * Defaults to "", can not start with `/` */ pathPrefix?: string; /** * This is prepended to the base file name, * which is `<pathPrefix>/?<namePrefix>[entry].YYYYMMDDHHmmss.zip` * * plugin will ensure a slash between `pathPrefix` and `name` if `pathPrefix` * is not empty */ namePrefix?: string; /** * Optional handlebars style template. * `entry` and `timestamp` are predefined * * Default: `{{entry}}-{{timestamp}}` */ keyTemplate?: string; } : {}); export declare type AWSDeployConfig<Storage extends AutoDeployStorage> = { config?: Partial<AWS.Config>; storage: AWSDeployStorageConfig<Storage>; }; export declare type AWSAutoDeployPluginConfig<Storage extends AutoDeployStorage = any> = { aws?: AWSDeployConfig<Storage>; /** * Mappings can avoid lambda updates by not specifying `fn` * * If you simply provider the function name and not * an array of 1..n mappings - your base file must be named `main`, * this is webpack's default output name. When would mean the * configured call would look similar to `main.handler` */ mappings: string | EntryMapping[]; preDeployScript?: string; verbose?: boolean; }; export declare const DefaultEntryName = "main";