Skip to content

Commit

Permalink
fix: skip asset creation when deploy is being made with exclusively f…
Browse files Browse the repository at this point in the history
…lag (#161)
  • Loading branch information
okarlsson authored Oct 31, 2023
1 parent 15deeb7 commit d73b6ef
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/NextjsStaticAssets.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as fs from 'node:fs';
import { tmpdir } from 'node:os';
import { resolve } from 'node:path';
import { RemovalPolicy } from 'aws-cdk-lib';
import { RemovalPolicy, Stack } from 'aws-cdk-lib';
import * as s3 from 'aws-cdk-lib/aws-s3';
import { Asset } from 'aws-cdk-lib/aws-s3-assets';
import { Construct } from 'constructs';
Expand Down Expand Up @@ -63,8 +63,12 @@ export class NextjsStaticAssets extends Construct {
this.props = props;

this.bucket = this.createBucket();
const asset = this.createAsset();
this.createBucketDeployment(asset);

// when `cdk deploy "NonNextjsStack" --exclusively` is run, don't bundle assets since they will not exist
if (Stack.of(this).bundlingRequired) {
const asset = this.createAsset();
this.createBucketDeployment(asset);
}
}

private createBucket(): s3.IBucket {
Expand Down

0 comments on commit d73b6ef

Please sign in to comment.