Fix astro sync config merge (#6392)
* Fix astro sync config merge * Fix getViteConfig type
This commit is contained in:
parent
c1ca84a8c1
commit
ee8b2a0672
3 changed files with 27 additions and 26 deletions
5
.changeset/cold-mirrors-joke.md
Normal file
5
.changeset/cold-mirrors-joke.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'astro': patch
|
||||
---
|
||||
|
||||
Run astro sync in build mode
|
|
@ -30,7 +30,7 @@ interface CreateViteOptions {
|
|||
settings: AstroSettings;
|
||||
logging: LogOptions;
|
||||
mode: 'dev' | 'build' | string;
|
||||
// will be undefined when using `sync`
|
||||
// will be undefined when using `getViteConfig`
|
||||
command?: 'dev' | 'build';
|
||||
fs?: typeof nodeFs;
|
||||
}
|
||||
|
@ -180,10 +180,8 @@ export async function createVite(
|
|||
// We also need to filter out the plugins that are not meant to be applied to the current command:
|
||||
// - If the command is `build`, we filter out the plugins that are meant to be applied for `serve`.
|
||||
// - If the command is `dev`, we filter out the plugins that are meant to be applied for `build`.
|
||||
if (command) {
|
||||
let plugins = settings.config.vite?.plugins;
|
||||
if (plugins) {
|
||||
const { plugins: _, ...rest } = settings.config.vite;
|
||||
if (command && settings.config.vite?.plugins) {
|
||||
let { plugins, ...rest } = settings.config.vite;
|
||||
const applyToFilter = command === 'build' ? 'serve' : 'build';
|
||||
const applyArgs = [
|
||||
{ ...settings.config.vite, mode },
|
||||
|
@ -201,12 +199,10 @@ export async function createVite(
|
|||
|
||||
return true;
|
||||
});
|
||||
|
||||
result = vite.mergeConfig(result, { ...rest, plugins });
|
||||
} else {
|
||||
result = vite.mergeConfig(result, settings.config.vite || {});
|
||||
}
|
||||
}
|
||||
result = vite.mergeConfig(result, commandConfig);
|
||||
if (result.plugins) {
|
||||
sortPlugins(result.plugins);
|
||||
|
|
|
@ -39,7 +39,7 @@ export async function sync(
|
|||
optimizeDeps: { entries: [] },
|
||||
logLevel: 'silent',
|
||||
},
|
||||
{ settings, logging, mode: 'build', fs }
|
||||
{ settings, logging, mode: 'build', command: 'build', fs }
|
||||
)
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in a new issue