Skip to content

Commit

Permalink
feat: allow custom buildPath
Browse files Browse the repository at this point in the history
  • Loading branch information
khuezy committed Dec 14, 2022
1 parent 0bd62c5 commit 00e12a4
Show file tree
Hide file tree
Showing 4 changed files with 128 additions and 1 deletion.
1 change: 1 addition & 0 deletions .eslintrc.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

119 changes: 119 additions & 0 deletions API.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions src/NextjsBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ export interface NextjsBaseProps {
*/
readonly nextjsPath: string;

/**
* The path to execute `npm run build`. By default, it uses `nextjsPath`.
* Can be overridden, particularly useful for monorepos where `build` is expected to run
* at the root of the project.
*/
readonly buildPath?: string;

/**
* Custom environment variables to pass to the NextJS build and runtime.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/NextjsBuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export class NextjsBuild extends Construct {
// run build
console.debug('├ Running "npm build" in', nextjsPath);
const buildResult = spawn.sync('npm', ['run', 'build'], {
cwd: nextjsPath,
cwd: this.props.buildPath ?? nextjsPath,
stdio: this.props.quiet ? 'ignore' : 'inherit',
env: buildEnv,
});
Expand Down

0 comments on commit 00e12a4

Please sign in to comment.