Skip to content

Commit

Permalink
use framework build target in NODE_ENV for production Vite builds (#6644
Browse files Browse the repository at this point in the history
)
  • Loading branch information
leoortizz committed Jan 23, 2024
1 parent 923edb7 commit d0972f7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
- Prevent the use of pinTags + minInstances on the same function, as the features are not mutually compatible (#6684)
- Add force flag to delete backend (#6635).
- Use framework build target in Vite builds (#6643).
- Use framework build target in NODE_ENV for production Vite builds (#6644)
9 changes: 9 additions & 0 deletions src/frameworks/vite/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,18 @@ export async function build(root: string, target: string) {
// SvelteKit uses process.cwd() unfortunately, chdir
const cwd = process.cwd();
process.chdir(root);

const originalNodeEnv = process.env.NODE_ENV;
// @ts-expect-error - NODE_ENV is `development` when building for production
// temporarily replace with target during build
process.env.NODE_ENV = target;

await build({ root, mode: target });
process.chdir(cwd);

// @ts-expect-error - restore NODE_ENV after build
process.env.NODE_ENV = originalNodeEnv;

return { rewrites: [{ source: "**", destination: "/index.html" }] };
}

Expand Down

0 comments on commit d0972f7

Please sign in to comment.