import { IDistribution } from 'aws-cdk-lib/aws-cloudfront'; import { ComputeType } from 'aws-cdk-lib/aws-codebuild'; import { IGrantable, IPrincipal } from 'aws-cdk-lib/aws-iam'; import { IBucket } from 'aws-cdk-lib/aws-s3'; import { AssetProps } from 'aws-cdk-lib/aws-s3-assets'; import { Construct } from 'constructs'; export { ComputeType } from 'aws-cdk-lib/aws-codebuild'; /** * Cache type for NodejsBuild. */ export declare enum CacheType { /** * S3 caching. Stores the npm cache directory in an S3 bucket. * Good for builds that run on different hosts. */ S3 = "S3", /** * Local caching. Stores the npm cache directory on the build host. * Faster than S3 but only effective if builds run on the same host. * Not supported with VPC or certain compute types. */ LOCAL = "LOCAL" } export interface AssetConfig extends AssetProps { /** * Shell commands executed right after the asset zip is extracted to the build environment. * @default No command is executed. */ readonly commands?: string[]; /** * Relative path from a build directory to the directory where the asset is extracted. * @default basename of the asset path. */ readonly extractPath?: string; } export interface NodejsBuildProps { /** * The AssetProps from which s3-assets are created and copied to the build environment. */ readonly assets: AssetConfig[]; /** * Environment variables injected to the build environment. * You can use CDK deploy-time values as well as literals. * @default {} */ readonly buildEnvironment?: { [key: string]: string; }; /** * S3 Bucket to which your build artifacts are finally deployed. */ readonly destinationBucket: IBucket; /** * Key prefix to deploy your build artifact. * @default '/' */ readonly destinationKeyPrefix?: string; /** * The distribution you are using to publish you build artifact. * If any specified, the caches are invalidated on new artifact deployments. * @default No distribution */ readonly distribution?: IDistribution; /** * Shell commands to build your project. They are executed on the working directory you specified. * @default ['npm run build'] */ readonly buildCommands?: string[]; /** * Relative path from the build directory to the directory where build commands run. * @default assetProps[0].extractPath */ readonly workingDirectory?: string; /** * Relative path from the working directory to the directory where the build artifacts are output. */ readonly outputSourceDirectory: string; /** * The version of Node.js to use in a build environment. Available versions: 12, 14, 16, 18, 20, 22, and 24. */ readonly nodejsVersion: number; /** * If true, a .env file is uploaded to an S3 bucket with values of `buildEnvironment` property. * You can copy it to your local machine by running the command in the stack output. * @default false */ readonly outputEnvFile?: boolean; /** * If true, common unnecessary files/directories such as .DS_Store, .git, node_modules, etc are excluded * from the assets by default. * @default true */ readonly excludeCommonFiles?: boolean; /** * Cache type for the npm cache directory. * @default - No caching */ readonly cache?: CacheType; /** * The type of compute to use for this build. * @default ComputeType.SMALL */ readonly computeType?: ComputeType; } /** * Build Node.js app and optionally publish the artifact to an S3 bucket. */ export declare class NodejsBuild extends Construct implements IGrantable { readonly grantPrincipal: IPrincipal; constructor(scope: Construct, id: string, props: NodejsBuildProps); }