diff --git a/packages/astro/src/@types/astro.ts b/packages/astro/src/@types/astro.ts index ea3e5cd3c..9a68f8397 100644 --- a/packages/astro/src/@types/astro.ts +++ b/packages/astro/src/@types/astro.ts @@ -84,6 +84,7 @@ export interface CLIFlags { port?: number; config?: string; drafts?: boolean; + skipSync?: boolean; } export interface BuildConfig { diff --git a/packages/astro/src/cli/index.ts b/packages/astro/src/cli/index.ts index 7c894fa09..66b7d3141 100644 --- a/packages/astro/src/cli/index.ts +++ b/packages/astro/src/cli/index.ts @@ -59,6 +59,7 @@ function printAstroHelp() { ['--base ', 'Specify your project base.'], ['--verbose', 'Enable verbose logging.'], ['--silent', 'Disable all logging.'], + ['--skip-sync', 'Skip automatic content type generation.'], ['--version', 'Show the version number and exit.'], ['--help', 'Show this help message.'], ], @@ -203,7 +204,12 @@ async function runCommand(cmd: string, flags: yargs.Arguments) { case 'build': { const { default: build } = await import('../core/build/index.js'); - return await build(settings, { ...flags, logging, telemetry }); + return await build(settings, { + mode: flags.mode, + skipSync: flags['skip-sync'], + logging, + telemetry, + }); } case 'check': { diff --git a/packages/astro/src/core/build/index.ts b/packages/astro/src/core/build/index.ts index 638d78d10..5bec50ad9 100644 --- a/packages/astro/src/core/build/index.ts +++ b/packages/astro/src/core/build/index.ts @@ -23,6 +23,7 @@ import { getTimeStat } from './util.js'; export interface BuildOptions { mode?: RuntimeMode; + skipSync?: boolean; logging: LogOptions; telemetry: AstroTelemetry; } @@ -38,6 +39,7 @@ class AstroBuilder { private settings: AstroSettings; private logging: LogOptions; private mode: RuntimeMode = 'production'; + private skipSync: boolean = false; private origin: string; private routeCache: RouteCache; private manifest: ManifestData; @@ -47,6 +49,9 @@ class AstroBuilder { if (options.mode) { this.mode = options.mode; } + if (options.skipSync) { + this.skipSync = options.skipSync; + } this.settings = settings; this.logging = options.logging; this.routeCache = new RouteCache(this.logging); @@ -81,10 +86,12 @@ class AstroBuilder { ); await runHookConfigDone({ settings: this.settings, logging }); - const { sync } = await import('../sync/index.js'); - const syncRet = await sync(this.settings, { logging, fs }); - if (syncRet !== 0) { - return process.exit(syncRet); + if (!this.skipSync) { + const { sync } = await import('../sync/index.js'); + const syncRet = await sync(this.settings, { logging, fs }); + if (syncRet !== 0) { + return process.exit(syncRet); + } } return { viteConfig }; diff --git a/packages/astro/src/core/dev/dev.ts b/packages/astro/src/core/dev/dev.ts index 4fcac87fa..f3d162674 100644 --- a/packages/astro/src/core/dev/dev.ts +++ b/packages/astro/src/core/dev/dev.ts @@ -72,7 +72,9 @@ export default async function dev( warn(options.logging, null, msg.fsStrictWarning()); } - await attachContentServerListeners(restart.container); + if (!options.flags?.['skip-sync']) { + await attachContentServerListeners(restart.container); + } return { address: devServerAddressInfo,