fix: do not apply user plugins when spawning temporary Vite server for content collections
This commit is contained in:
parent
4d75396362
commit
ccaed8f74b
3 changed files with 12 additions and 3 deletions
5
.changeset/quick-items-switch.md
Normal file
5
.changeset/quick-items-switch.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'astro': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix regression that caused some stateful Vite plugins to assume they were running in `dev` mode during the `build`.
|
|
@ -31,6 +31,7 @@ interface CreateViteOptions {
|
||||||
logging: LogOptions;
|
logging: LogOptions;
|
||||||
mode: 'dev' | 'build' | string;
|
mode: 'dev' | 'build' | string;
|
||||||
fs?: typeof nodeFs;
|
fs?: typeof nodeFs;
|
||||||
|
allowUserPlugins?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ALWAYS_NOEXTERNAL = [
|
const ALWAYS_NOEXTERNAL = [
|
||||||
|
@ -48,7 +49,7 @@ const ALWAYS_NOEXTERNAL = [
|
||||||
/** Return a common starting point for all Vite actions */
|
/** Return a common starting point for all Vite actions */
|
||||||
export async function createVite(
|
export async function createVite(
|
||||||
commandConfig: vite.InlineConfig,
|
commandConfig: vite.InlineConfig,
|
||||||
{ settings, logging, mode, fs = nodeFs }: CreateViteOptions
|
{ settings, logging, mode, fs = nodeFs, allowUserPlugins = true }: CreateViteOptions
|
||||||
): Promise<vite.InlineConfig> {
|
): Promise<vite.InlineConfig> {
|
||||||
const astroPkgsConfig = await crawlFrameworkPkgs({
|
const astroPkgsConfig = await crawlFrameworkPkgs({
|
||||||
root: fileURLToPath(settings.config.root),
|
root: fileURLToPath(settings.config.root),
|
||||||
|
@ -170,7 +171,9 @@ export async function createVite(
|
||||||
// 3. integration-provided vite config, via the `config:setup` hook
|
// 3. integration-provided vite config, via the `config:setup` hook
|
||||||
// 4. command vite config, passed as the argument to this function
|
// 4. command vite config, passed as the argument to this function
|
||||||
let result = commonConfig;
|
let result = commonConfig;
|
||||||
result = vite.mergeConfig(result, settings.config.vite || {});
|
if (allowUserPlugins) {
|
||||||
|
result = vite.mergeConfig(result, settings.config.vite || {});
|
||||||
|
}
|
||||||
result = vite.mergeConfig(result, commandConfig);
|
result = vite.mergeConfig(result, commandConfig);
|
||||||
if (result.plugins) {
|
if (result.plugins) {
|
||||||
sortPlugins(result.plugins);
|
sortPlugins(result.plugins);
|
||||||
|
|
|
@ -39,7 +39,8 @@ export async function sync(
|
||||||
optimizeDeps: { entries: [] },
|
optimizeDeps: { entries: [] },
|
||||||
logLevel: 'silent',
|
logLevel: 'silent',
|
||||||
},
|
},
|
||||||
{ settings, logging, mode: 'build', fs }
|
// Important to disallow user-provided Vite plugins that might be stateful!
|
||||||
|
{ settings, logging, mode: 'build', fs, allowUserPlugins: false }
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue