fix(vite): take into account configuration for build mode (#13655)

This commit is contained in:
Katerina Skroumpelou 2022-12-06 15:31:40 +02:00 committed by GitHub
parent 7d329c0590
commit 01b3ebd00d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 6 deletions

View File

@ -9,5 +9,5 @@ export interface ViteBuildExecutorOptions {
manifest?: boolean | string; manifest?: boolean | string;
ssrManifest?: boolean | string; ssrManifest?: boolean | string;
logLevel?: 'info' | 'warn' | 'error' | 'silent'; logLevel?: 'info' | 'warn' | 'error' | 'silent';
mode?: string; mode?: 'production' | 'development';
} }

View File

@ -16,7 +16,7 @@ export default async function* viteDevServerExecutor(
context: ExecutorContext context: ExecutorContext
): AsyncGenerator<{ success: boolean; baseUrl: string }> { ): AsyncGenerator<{ success: boolean; baseUrl: string }> {
const mergedOptions = { const mergedOptions = {
...getBuildTargetOptions(options, context), ...getBuildTargetOptions(options.buildTarget, context),
...options, ...options,
} as ViteDevServerExecutorOptions & ViteBuildExecutorOptions; } as ViteDevServerExecutorOptions & ViteBuildExecutorOptions;

View File

@ -9,6 +9,6 @@ export interface ViteDevServerExecutorOptions {
open?: string | boolean; open?: string | boolean;
cors?: boolean; cors?: boolean;
logLevel?: info | warn | error | silent; logLevel?: info | warn | error | silent;
mode?: string; mode?: 'production' | 'development';
clearScreen?: boolean; clearScreen?: boolean;
} }

View File

@ -28,7 +28,7 @@ export async function getBuildAndSharedConfig(
const projectRoot = context.workspace.projects[context.projectName].root; const projectRoot = context.workspace.projects[context.projectName].root;
return mergeConfig({}, { return mergeConfig({}, {
mode: options.mode, mode: options.mode ?? context.configurationName,
root: projectRoot, root: projectRoot,
base: options.base, base: options.base,
configFile: normalizeConfigFilePath( configFile: normalizeConfigFilePath(
@ -97,10 +97,10 @@ export function getServerOptions(
} }
export function getBuildTargetOptions( export function getBuildTargetOptions(
options: ViteDevServerExecutorOptions, buildTarget: string,
context: ExecutorContext context: ExecutorContext
) { ) {
const target = parseTargetString(options.buildTarget); const target = parseTargetString(buildTarget);
return readTargetOptions(target, context); return readTargetOptions(target, context);
} }