From edb7bead6e42b463dce0f6837ea78ae733eab88b Mon Sep 17 00:00:00 2001 From: Rishi Raj Jain Date: Fri, 23 Sep 2022 17:38:57 +0530 Subject: [PATCH] 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 --- .changeset/short-ravens-marry.md | 5 +++++ packages/astro/src/cli/index.ts | 2 +- packages/astro/src/core/build/static-build.ts | 4 ++-- 3 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 .changeset/short-ravens-marry.md diff --git a/.changeset/short-ravens-marry.md b/.changeset/short-ravens-marry.md new file mode 100644 index 000000000000..c8aed9bcc834 --- /dev/null +++ b/.changeset/short-ravens-marry.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +add support for changing mode via CLI diff --git a/packages/astro/src/cli/index.ts b/packages/astro/src/cli/index.ts index 8263cc19b8e3..93e589396fd9 100644 --- a/packages/astro/src/cli/index.ts +++ b/packages/astro/src/cli/index.ts @@ -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': { diff --git a/packages/astro/src/core/build/static-build.ts b/packages/astro/src/core/build/static-build.ts index 58d3c6c568e4..40237659fc40 100644 --- a/packages/astro/src/core/build/static-build.ts +++ b/packages/astro/src/core/build/static-build.ts @@ -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,