@@ -422,25 +422,40 @@ export async function renderProject(
422422 ) ;
423423 } ) ;
424424
425- // copy all of the resource files
426- const allResourceFiles = ld . uniq (
427- ( context . files . resources || [ ] ) . concat (
428- projResults . files . flatMap ( ( file ) => file . resourceFiles ) ,
429- ) ,
430- ) ;
425+ // Expand the resources into the format aware targets
426+ const resourceFilesToCopy : Record < string , Set < string > > = { } ;
427+ projResults . files . forEach ( ( file ) => {
428+ const formatOutputDir = projectFormatOutputDir (
429+ file . format ,
430+ context ,
431+ projType ,
432+ ) ;
433+ file . resourceFiles . forEach ( ( file ) => {
434+ resourceFilesToCopy [ file ] = resourceFilesToCopy [ file ] || new Set ( ) ;
435+ const relativePath = relative ( projDir , file ) ;
436+ resourceFilesToCopy [ file ] . add ( join ( formatOutputDir , relativePath ) ) ;
437+ } ) ;
438+ } ) ;
431439
432- // copy the resource files to the output dir
433- allResourceFiles . forEach ( ( file : string ) => {
434- const sourcePath = relative ( projDir , file ) ;
435- const destPath = join ( outputDirAbsolute , sourcePath ) ;
436- if ( existsSync ( file ) ) {
437- if ( Deno . statSync ( file ) . isFile ) {
438- copyResourceFile ( context . dir , file , destPath ) ;
440+ let count = 0 ;
441+ let duped = 0 ;
442+ Object . keys ( resourceFilesToCopy ) . forEach ( ( srcPath ) => {
443+ const destinationFiles = resourceFilesToCopy [ srcPath ] ;
444+ destinationFiles . forEach ( ( destPath : string ) => {
445+ if ( existsSync ( srcPath ) ) {
446+ if ( Deno . statSync ( srcPath ) . isFile ) {
447+ copyResourceFile ( context . dir , srcPath , destPath ) ;
448+ console . log ( destPath ) ;
449+ count ++ ;
450+ }
451+ } else if ( ! existsSync ( destPath ) ) {
452+ warning ( `File '${ srcPath } ' was not found.` ) ;
453+ } else {
454+ duped ++ ;
439455 }
440- } else if ( ! existsSync ( destPath ) ) {
441- warning ( `File '${ sourcePath } ' was not found.` ) ;
442- }
456+ } ) ;
443457 } ) ;
458+ console . log ( `${ count } files copied, ${ duped } dupes` ) ;
444459 } else {
445460 for ( const result of fileResults . files ) {
446461 const resourceFiles = await resourcesFrom ( result ) ;
0 commit comments