Skip to content

Commit

Permalink
fix: fixes ssg cache files not being used by open-next cache handler (#…
Browse files Browse the repository at this point in the history
…150)

* fix: fixes ssg cache files not being used by open-next cache handler

Closes #149

This will align the cache files generated at deploy time and the open-next cache handler so SSG files are actually looked at.

* use _cache instead of cache

This probably makes sense, using the generally familiar `_` prefix to indicate internal use.

* keep nextjs cache dir config

* third time is the charm - making sure the path for the nextjs cache is correct.

---------

Co-authored-by: Kevin Mitchell <>
  • Loading branch information
kevin-mitchell authored Oct 23, 2023
1 parent 91fbcd7 commit 350933a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/NextjsBuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import {
NEXTJS_BUILD_IMAGE_FN_DIR,
NEXTJS_BUILD_REVALIDATE_FN_DIR,
NEXTJS_BUILD_SERVER_FN_DIR,
NEXTJS_CACHE_DIR,
NEXTJS_STATIC_DIR,
NEXTJS_CACHE_DIR,
} from './constants';
import { NextjsBaseProps } from './NextjsBase';
import { NextjsBucketDeployment } from './NextjsBucketDeployment';
Expand Down
4 changes: 2 additions & 2 deletions src/NextjsStaticAssets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { RemovalPolicy } 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';
import { NEXTJS_CACHE_DIR } from './constants';
import { CACHE_BUCKET_KEY_PREFIX } from './constants';
import { NextjsBucketDeployment } from './NextjsBucketDeployment';
import { NextjsBuild } from './NextjsBuild';

Expand Down Expand Up @@ -84,7 +84,7 @@ export class NextjsStaticAssets extends Construct {
// create temporary directory to join open-next's static output with cache output
const tmpAssetsDir = fs.mkdtempSync(resolve(tmpdir(), 'cdk-nextjs-assets-'));
fs.cpSync(this.props.nextBuild.nextStaticDir, tmpAssetsDir, { recursive: true });
fs.cpSync(this.props.nextBuild.nextCacheDir, resolve(tmpAssetsDir, NEXTJS_CACHE_DIR), { recursive: true });
fs.cpSync(this.props.nextBuild.nextCacheDir, resolve(tmpAssetsDir, CACHE_BUCKET_KEY_PREFIX), { recursive: true });
const asset = new Asset(this, 'Asset', {
path: tmpAssetsDir,
});
Expand Down

0 comments on commit 350933a

Please sign in to comment.