fix(vite): fix watch schema for build executor to object or boolean i… (#14756)
This commit is contained in:
parent
f794a1f436
commit
259d4b29cf
@ -81,8 +81,8 @@
|
|||||||
},
|
},
|
||||||
"watch": {
|
"watch": {
|
||||||
"description": "Enable re-building when files change.",
|
"description": "Enable re-building when files change.",
|
||||||
"type": "object",
|
"oneOf": [{ "type": "boolean" }, { "type": "object" }],
|
||||||
"default": null
|
"default": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"definitions": {},
|
"definitions": {},
|
||||||
|
|||||||
@ -15,13 +15,14 @@ export default async function* viteBuildExecutor(
|
|||||||
options: ViteBuildExecutorOptions,
|
options: ViteBuildExecutorOptions,
|
||||||
context: ExecutorContext
|
context: ExecutorContext
|
||||||
) {
|
) {
|
||||||
|
const normalizedOptions = normalizeOptions(options);
|
||||||
const projectRoot =
|
const projectRoot =
|
||||||
context.projectsConfigurations.projects[context.projectName].root;
|
context.projectsConfigurations.projects[context.projectName].root;
|
||||||
|
|
||||||
const buildConfig = mergeConfig(
|
const buildConfig = mergeConfig(
|
||||||
getViteSharedConfig(options, false, context),
|
getViteSharedConfig(normalizedOptions, false, context),
|
||||||
{
|
{
|
||||||
build: getViteBuildOptions(options, context),
|
build: getViteBuildOptions(normalizedOptions, context),
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -37,7 +38,7 @@ export default async function* viteBuildExecutor(
|
|||||||
) {
|
) {
|
||||||
await copyAssets(
|
await copyAssets(
|
||||||
{
|
{
|
||||||
outputPath: options.outputPath,
|
outputPath: normalizedOptions.outputPath,
|
||||||
assets: [
|
assets: [
|
||||||
{
|
{
|
||||||
input: projectRoot,
|
input: projectRoot,
|
||||||
@ -79,3 +80,16 @@ function runInstance(options: InlineConfig) {
|
|||||||
...options,
|
...options,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function normalizeOptions(options: ViteBuildExecutorOptions) {
|
||||||
|
const normalizedOptions = { ...options };
|
||||||
|
|
||||||
|
// coerce watch to null or {} to match with Vite's watch config
|
||||||
|
if (options.watch === false) {
|
||||||
|
normalizedOptions.watch = null;
|
||||||
|
} else if (options.watch === true) {
|
||||||
|
normalizedOptions.watch = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
return normalizedOptions;
|
||||||
|
}
|
||||||
|
|||||||
@ -12,5 +12,5 @@ export interface ViteBuildExecutorOptions {
|
|||||||
logLevel?: 'info' | 'warn' | 'error' | 'silent';
|
logLevel?: 'info' | 'warn' | 'error' | 'silent';
|
||||||
mode?: string;
|
mode?: string;
|
||||||
ssr?: boolean | string;
|
ssr?: boolean | string;
|
||||||
watch?: object | null;
|
watch?: object | boolean;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -121,8 +121,15 @@
|
|||||||
},
|
},
|
||||||
"watch": {
|
"watch": {
|
||||||
"description": "Enable re-building when files change.",
|
"description": "Enable re-building when files change.",
|
||||||
"type": "object",
|
"oneOf": [
|
||||||
"default": null
|
{
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "object"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"default": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"definitions": {},
|
"definitions": {},
|
||||||
|
|||||||
@ -142,7 +142,7 @@ export function getViteBuildOptions(
|
|||||||
manifest: options.manifest,
|
manifest: options.manifest,
|
||||||
ssrManifest: options.ssrManifest,
|
ssrManifest: options.ssrManifest,
|
||||||
ssr: options.ssr,
|
ssr: options.ssr,
|
||||||
watch: options.watch,
|
watch: options.watch as BuildOptions['watch'],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user