fix: Can't overwrite vite's MODE environment variable (#4850)

* Add flags to the build options

* replace mode: 'production' as fallback

* Update mode support

* Add changeset
This commit is contained in:
Rishi Raj Jain 2022-09-23 17:38:57 +05:30 committed by GitHub
parent ee5fdeffdd
commit edb7bead6e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 3 deletions

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
add support for changing mode via CLI

View file

@ -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': {

View file

@ -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,
@ -193,8 +193,8 @@ async function clientBuild(
const viteBuildConfig = {
...viteConfig,
mode: viteConfig.mode || 'production',
logLevel: 'info',
mode: 'production',
build: {
target: 'esnext',
...viteConfig.build,