@@ -216,6 +216,11 @@ export const build = async ({
216216 spinner . text = 'Deleting pre-existing modified preview app folder' ;
217217 await fs . promises . rm ( modifiedPreviewAppPath , { recursive : true } ) ;
218218 }
219+ const builtPreviewAppPath = path . join ( process . cwd ( ) , '.react-email' ) ;
220+ if ( fs . existsSync ( builtPreviewAppPath ) ) {
221+ spinner . text = 'Deleting pre-existing .react-email folder' ;
222+ await fs . promises . rm ( builtPreviewAppPath , { recursive : true } ) ;
223+ }
219224
220225 spinner . text = 'Copying preview app from CLI to modify it' ;
221226 await fs . promises . cp ( previewServerLocation , modifiedPreviewAppPath , {
@@ -259,24 +264,25 @@ export const build = async ({
259264 } ) ;
260265 await buildPreviewApp ( modifiedPreviewAppPath ) ;
261266
267+ await fs . promises . mkdir ( builtPreviewAppPath ) ;
262268 await fs . promises . cp (
263269 path . join ( modifiedPreviewAppPath , '.next' ) ,
264- path . join ( process . cwd ( ) , '.next' ) ,
270+ path . join ( builtPreviewAppPath , '.next' ) ,
265271 {
266272 recursive : true ,
267273 } ,
268274 ) ;
269- // await fs.promises.cp(
270- // path.join(modifiedPreviewAppPath, 'public'),
271- // path.join(builtPreviewAppPath, 'public'),
272- // {
273- // recursive: true,
274- // },
275- // );
276-
277- // await fs.promises.rm(modifiedPreviewAppPath, {
278- // recursive: true,
279- // });
275+ await fs . promises . cp (
276+ path . join ( modifiedPreviewAppPath , 'public' ) ,
277+ path . join ( builtPreviewAppPath , 'public' ) ,
278+ {
279+ recursive : true ,
280+ } ,
281+ ) ;
282+
283+ await fs . promises . rm ( modifiedPreviewAppPath , {
284+ recursive : true ,
285+ } ) ;
280286 } catch ( error ) {
281287 console . log ( error ) ;
282288 process . exit ( 1 ) ;
0 commit comments