Skip to content
This repository was archived by the owner on Jan 28, 2025. It is now read-only.

Commit 0c138a2

Browse files
authored
feat(lambda-at-edge): add a binary to allow use without copying example (#688)
1 parent 05fb0eb commit 0c138a2

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

packages/libs/lambda-at-edge/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
"description": "Provides handlers that can be used in CloudFront Lambda@Edge to deploy next.js applications to the edge",
88
"main": "dist/index.js",
99
"types": "dist/index.d.ts",
10+
"bin": {
11+
"build-lambda-at-edge": "src/command.js"
12+
},
1013
"scripts": {
1114
"prepare": "yarn build",
1215
"build": "rollup --config && tsc -p tsconfig.build.json"
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { default as Builder } from "./build";
2+
import { join } from "path";
3+
4+
async function main(args: string[]) {
5+
if (args.length > 1) {
6+
console.error("Usage: build-lambda-at-edge [ NEXT_APP_DIR ]");
7+
process.exit(1);
8+
}
9+
10+
const nextConfigDir = args[0] || ".";
11+
const outputDir = join(nextConfigDir, ".serverless_nextjs");
12+
13+
const builder = new Builder(nextConfigDir, outputDir, {
14+
cmd: "./node_modules/.bin/next",
15+
cwd: process.cwd(),
16+
env: {},
17+
args: ["build"]
18+
});
19+
20+
await builder.build();
21+
}
22+
23+
main(process.argv.slice(2)).catch((err) => {
24+
console.error(err);
25+
process.exit(1);
26+
});

0 commit comments

Comments
 (0)