Skip to content
This repository was archived by the owner on May 10, 2021. It is now read-only.

Commit aa7723b

Browse files
throw error if .next/static cannot be found (#148)
* throw error if .next/static cannot be found * throw new Error Co-authored-by: ehmicky <[email protected]> Co-authored-by: ehmicky <[email protected]>
1 parent 6a557cd commit aa7723b

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

lib/steps/copyNextAssets.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
const { join } = require("path");
2-
const { copySync } = require("fs-extra");
2+
const { copySync, existsSync } = require("fs-extra");
33
const { logTitle } = require("../helpers/logger");
44
const { NEXT_DIST_DIR } = require("../config");
55

66
// Copy the NextJS' static assets from NextJS distDir to Netlify publish folder.
77
// These need to be available for NextJS to work.
88
const copyNextAssets = (publishPath) => {
9+
const staticAssetsPath = join(NEXT_DIST_DIR, "static");
10+
if (!existsSync(staticAssetsPath)) {
11+
throw new Error("No static assets found in .next dist (aka no /.next/static). Please check your project configuration. Your next.config.js must be one of `serverless` or `experimental-serverless-trace`. Your build command should include `next build`.");
12+
}
913
logTitle("💼 Copying static NextJS assets to", publishPath);
10-
copySync(
11-
join(NEXT_DIST_DIR, "static"),
12-
join(publishPath, "_next", "static"),
13-
{
14-
overwrite: false,
15-
errorOnExist: true,
16-
}
17-
);
14+
copySync(staticAssetsPath, join(publishPath, "_next", "static"), {
15+
overwrite: false,
16+
errorOnExist: true,
17+
});
1818
};
1919

2020
module.exports = copyNextAssets;

0 commit comments

Comments
 (0)