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,