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": {
|
||||
"description": "Enable re-building when files change.",
|
||||
"type": "object",
|
||||
"default": null
|
||||
"oneOf": [{ "type": "boolean" }, { "type": "object" }],
|
||||
"default": false
|
||||
}
|
||||
},
|
||||
"definitions": {},
|
||||
|
||||
@ -15,13 +15,14 @@ export default async function* viteBuildExecutor(
|
||||
options: ViteBuildExecutorOptions,
|
||||
context: ExecutorContext
|
||||
) {
|
||||
const normalizedOptions = normalizeOptions(options);
|
||||
const projectRoot =
|
||||
context.projectsConfigurations.projects[context.projectName].root;
|
||||
|
||||
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(
|
||||
{
|
||||
outputPath: options.outputPath,
|
||||
outputPath: normalizedOptions.outputPath,
|
||||
assets: [
|
||||
{
|
||||
input: projectRoot,
|
||||
@ -79,3 +80,16 @@ function runInstance(options: InlineConfig) {
|
||||
...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';
|
||||
mode?: string;
|
||||
ssr?: boolean | string;
|
||||
watch?: object | null;
|
||||
watch?: object | boolean;
|
||||
}
|
||||
|
||||
@ -121,8 +121,15 @@
|
||||
},
|
||||
"watch": {
|
||||
"description": "Enable re-building when files change.",
|
||||
"type": "object",
|
||||
"default": null
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"type": "object"
|
||||
}
|
||||
],
|
||||
"default": false
|
||||
}
|
||||
},
|
||||
"definitions": {},
|
||||
|
||||
@ -142,7 +142,7 @@ export function getViteBuildOptions(
|
||||
manifest: options.manifest,
|
||||
ssrManifest: options.ssrManifest,
|
||||
ssr: options.ssr,
|
||||
watch: options.watch,
|
||||
watch: options.watch as BuildOptions['watch'],
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user