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

Add a binary to allow use without copying example #688

Merged
merged 5 commits into from
Oct 22, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions packages/libs/lambda-at-edge/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
"description": "Provides handlers that can be used in CloudFront Lambda@Edge to deploy next.js applications to the edge",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"bin": {
"build-lambda-at-edge": "src/command.js"
},
"scripts": {
"prepare": "yarn build",
"build": "rollup --config && tsc -p tsconfig.build.json"
Expand Down
26 changes: 26 additions & 0 deletions packages/libs/lambda-at-edge/src/command.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { default as Builder } from "./build";
import { join } from "path";

async function main(args: string[]) {
if (args.length > 1) {
console.error("Usage: build-lambda-at-edge [ NEXT_APP_DIR ]");
process.exit(1);
}

const nextConfigDir = args[0] || ".";
const outputDir = join(nextConfigDir, ".serverless_nextjs");

const builder = new Builder(nextConfigDir, outputDir, {
cmd: "./node_modules/.bin/next",
cwd: process.cwd(),
env: {},
args: ["build"]
});

await builder.build();
}

main(process.argv.slice(2)).catch((err) => {
console.error(err);
process.exit(1);
});