Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions packages/open-next/src/build/copyTracedFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import url from "node:url";

import {
copyFileSync,
cpSync,
existsSync,
mkdirSync,
readFileSync,
Expand Down Expand Up @@ -331,17 +332,17 @@ File ${serverPath} does not exist
);
}
};

const manifests = getManifests(standaloneNextDir);
const { config, prerenderManifest, pagesManifest } = manifests;

// Get all the static files - Should be only for pages dir
// Ideally we would filter only those that might get accessed in this specific functions
// Maybe even move this to s3 directly
if (hasPageDir) {
// First we get truly static files - i.e. pages without getStaticProps
const staticFiles: Array<string> = Object.values(
loadPagesManifest(standaloneNextDir),
);
const staticFiles: Array<string> = Object.values(pagesManifest);
// Then we need to get all fallback: true dynamic routes html
const prerenderManifest = loadPrerenderManifest(standaloneNextDir);
const config = loadConfig(standaloneNextDir);
const locales = config.i18n?.locales;
Object.values(prerenderManifest.dynamicRoutes).forEach((route) => {
if (typeof route.fallback === "string") {
Expand All @@ -360,11 +361,21 @@ File ${serverPath} does not exist
.forEach((file) => copyStaticFile(`server/${file}`));
}

// Copy .next/static/css from standalone to output dir
// needed for optimizeCss feature to work
if (config.experimental.optimizeCss) {
cpSync(
path.join(standaloneNextDir, "static", "css"),
path.join(outputNextDir, "static", "css"),
{ recursive: true },
);
}

logger.debug("copyTracedFiles:", Date.now() - tsStart, "ms");

return {
tracedFiles,
nodePackages,
manifests: getManifests(standaloneNextDir),
manifests,
};
}
1 change: 1 addition & 0 deletions packages/open-next/src/types/next-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export interface NextConfig {
experimental: {
serverActions?: boolean;
appDir?: boolean;
optimizeCss?: boolean;
};
images: ImageConfig;
poweredByHeader?: boolean;
Expand Down