@@ -119,7 +119,15 @@ export interface AntVSiteConfig {
119119 demo ?: {
120120 height ?: number ;
121121 } ;
122- output ?: string ;
122+ /** @deprecated Configure Astro's standard `outDir` instead. */
123+ output ?: never ;
124+ }
125+
126+ export interface SiteWorkspacePaths {
127+ outDir ?: string ;
128+ srcDir ?: string ;
129+ publicDir ?: string ;
130+ cacheDir ?: string ;
123131}
124132
125133export interface ResolvedSiteConfig {
@@ -195,7 +203,6 @@ export interface ResolvedSiteConfig {
195203 demo : {
196204 height : number ;
197205 } ;
198- output : string ;
199206}
200207
201208const localizedTextSchema = z . strictObject ( {
@@ -428,7 +435,12 @@ const configSchema = z
428435 . default ( {
429436 height : 480 ,
430437 } ) ,
431- output : z . string ( ) . min ( 1 ) . default ( "./dist" ) ,
438+ output : z
439+ . never ( {
440+ error :
441+ "output was removed. Configure Astro's standard outDir instead." ,
442+ } )
443+ . optional ( ) ,
432444 } )
433445 . superRefine ( ( config , context ) => {
434446 if ( ! config . site . locales . includes ( config . site . defaultLocale ) ) {
@@ -529,7 +541,8 @@ async function validateOutputPath(
529541 root : string ,
530542 output : string ,
531543 content : Pick < ResolvedSiteConfig [ "content" ] , "docs" | "examples" > ,
532- ) : Promise < string > {
544+ workspace : SiteWorkspacePaths ,
545+ ) : Promise < void > {
533546 const physicalRoot = await resolvePhysicalPath ( root ) ;
534547 const physicalOutput = await resolvePhysicalPath ( output ) ;
535548 if (
@@ -544,7 +557,9 @@ async function validateOutputPath(
544557 const protectedPaths = [
545558 content . docs ,
546559 content . examples ,
547- resolve ( physicalRoot , "public" ) ,
560+ workspace . srcDir ?? resolve ( physicalRoot , "src" ) ,
561+ workspace . publicDir ?? resolve ( physicalRoot , "public" ) ,
562+ workspace . cacheDir ?? resolve ( physicalRoot , ".astro" ) ,
548563 resolve ( physicalRoot , ".antv-site" ) ,
549564 resolve ( physicalRoot , ".git" ) ,
550565 resolve ( physicalRoot , "node_modules" ) ,
@@ -557,17 +572,16 @@ async function validateOutputPath(
557572 isWithin ( physicalProtectedPath , physicalOutput )
558573 ) {
559574 throw new Error (
560- `Site output overlaps a protected input or workspace directory: ${ physicalOutput } ` ,
575+ `Site output overlaps a protected input or workspace directory: ${ physicalOutput } (protected: ${ physicalProtectedPath } ) ` ,
561576 ) ;
562577 }
563578 }
564-
565- return physicalOutput ;
566579}
567580
568581export async function resolveConfig (
569582 input : AntVSiteConfig ,
570583 consumerRoot : string ,
584+ workspace : SiteWorkspacePaths = { } ,
571585) : Promise < ResolvedSiteConfig > {
572586 const config = configSchema . parse ( input ) ;
573587 const root = await resolvePhysicalPath ( consumerRoot ) ;
@@ -578,10 +592,11 @@ export async function resolveConfig(
578592 ? resolveFromRoot ( root , config . content . examples )
579593 : null ,
580594 } ;
581- const output = await validateOutputPath (
595+ await validateOutputPath (
582596 root ,
583- resolveFromRoot ( root , config . output ) ,
597+ workspace . outDir ?? resolve ( root , "dist" ) ,
584598 content ,
599+ workspace ,
585600 ) ;
586601
587602 return {
@@ -615,6 +630,5 @@ export async function resolveConfig(
615630 ] ) ,
616631 ) as Record < HomeSlotName , string [ ] > ,
617632 } ,
618- output,
619633 } as ResolvedSiteConfig ;
620634}
0 commit comments