1
- import { exec , getPackageManager , Manifest } from '#utils' ;
1
+ import { exec , getPackageManager , Manifest , feedback } from '#utils' ;
2
+ import path from 'path' ;
3
+ import fs from 'fs-extra' ;
2
4
3
5
const packageManager = await getPackageManager ( ) ;
4
6
@@ -18,11 +20,39 @@ async function prebuild() {
18
20
19
21
Manifest . setRoute ( {
20
22
from : '/' ,
21
- to : '.edge/ storage' ,
23
+ to : path . join ( '.edge' , ' storage') ,
22
24
priority : 1 ,
23
25
type : 'deliver' ,
24
26
} ) ;
25
27
Manifest . generate ( ) ;
28
+
29
+ // Move the contents of the 'Browser' folder, which contains static files, to the root of the storage.
30
+ const oldPath = path . join ( process . cwd ( ) , '.edge' , 'storage' , 'browser' ) ;
31
+ const newPath = path . join ( process . cwd ( ) , '.edge' , 'storage' ) ;
32
+
33
+ const files = await fs . readdir ( oldPath ) ;
34
+ await Promise . all (
35
+ files . map ( async ( file ) => {
36
+ await fs . move ( path . join ( oldPath , file ) , path . join ( newPath , file ) ) ;
37
+ } ) ,
38
+ ) ;
39
+
40
+ // Remove the original folder
41
+ await fs . remove ( oldPath ) ;
42
+
43
+ // If the folder exists, it means that the application is using server-side rendering (SSR)
44
+ // functionalities. In this case, a warning message is logged.
45
+ const serverFolderPath = path . join (
46
+ process . cwd ( ) ,
47
+ '.edge' ,
48
+ 'storage' ,
49
+ 'server' ,
50
+ ) ;
51
+ if ( fs . existsSync ( serverFolderPath ) ) {
52
+ feedback . prebuild . warn (
53
+ `It looks like you are using SSR functionalities. Server-side functionality will not work in 'deliver' mode.` ,
54
+ ) ;
55
+ }
26
56
}
27
57
28
58
export default prebuild ;
0 commit comments