Skip to content

Commit

Permalink
fix: Can't overwrite vite's MODE environment variable (#4850)
Browse files Browse the repository at this point in the history
* Add flags to the build options

* replace mode: 'production' as fallback

* Update mode support

* Add changeset
  • Loading branch information
Rishi Raj Jain authored Sep 23, 2022
1 parent ee5fdef commit edb7bea
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/short-ravens-marry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

add support for changing mode via CLI
2 changes: 1 addition & 1 deletion packages/astro/src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ async function runCommand(cmd: string, flags: yargs.Arguments) {
}

case 'build': {
return await build(settings, { logging, telemetry });
return await build(settings, { ...flags, logging, telemetry });
}

case 'check': {
Expand Down
4 changes: 2 additions & 2 deletions packages/astro/src/core/build/static-build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ async function ssrBuild(opts: StaticBuildOptions, internals: BuildInternals, inp

const viteBuildConfig: ViteConfigWithSSR = {
...viteConfig,
mode: viteConfig.mode || 'production',
logLevel: opts.viteConfig.logLevel ?? 'error',
mode: 'production',
build: {
target: 'esnext',
...viteConfig.build,
Expand Down Expand Up @@ -193,8 +193,8 @@ async function clientBuild(

const viteBuildConfig = {
...viteConfig,
mode: viteConfig.mode || 'production',
logLevel: 'info',
mode: 'production',
build: {
target: 'esnext',
...viteConfig.build,
Expand Down

0 comments on commit edb7bea

Please sign in to comment.