@@ -213,6 +213,11 @@ export const build = async ({
213213 spinner . text = 'Deleting pre-existing modified preview app folder' ;
214214 await fs . promises . rm ( modifiedPreviewAppPath , { recursive : true } ) ;
215215 }
216+ const builtPreviewAppPath = path . join ( process . cwd ( ) , '.react-email' ) ;
217+ if ( fs . existsSync ( builtPreviewAppPath ) ) {
218+ spinner . text = 'Deleting pre-existing .react-email folder' ;
219+ await fs . promises . rm ( builtPreviewAppPath , { recursive : true } ) ;
220+ }
216221
217222 spinner . text = 'Copying preview app from CLI to modify it' ;
218223 await fs . promises . cp ( cliPackageLocation , modifiedPreviewAppPath , {
@@ -256,24 +261,25 @@ export const build = async ({
256261 } ) ;
257262 await buildPreviewApp ( modifiedPreviewAppPath ) ;
258263
264+ await fs . promises . mkdir ( builtPreviewAppPath ) ;
259265 await fs . promises . cp (
260266 path . join ( modifiedPreviewAppPath , '.next' ) ,
261- path . join ( process . cwd ( ) , '.next' ) ,
267+ path . join ( builtPreviewAppPath , '.next' ) ,
268+ {
269+ recursive : true ,
270+ } ,
271+ ) ;
272+ await fs . promises . cp (
273+ path . join ( modifiedPreviewAppPath , 'public' ) ,
274+ path . join ( builtPreviewAppPath , 'public' ) ,
262275 {
263276 recursive : true ,
264277 } ,
265278 ) ;
266- // await fs.promises.cp(
267- // path.join(modifiedPreviewAppPath, 'public'),
268- // path.join(builtPreviewAppPath, 'public'),
269- // {
270- // recursive: true,
271- // },
272- // );
273279
274- // await fs.promises.rm(modifiedPreviewAppPath, {
275- // recursive: true,
276- // });
280+ await fs . promises . rm ( modifiedPreviewAppPath , {
281+ recursive : true ,
282+ } ) ;
277283 } catch ( error ) {
278284 console . log ( error ) ;
279285 process . exit ( 1 ) ;
0 commit comments