Skip to content

Commit f8c12b6

Browse files
committed
fix: angular preset (deliver)
1 parent 5e3d933 commit f8c12b6

File tree

3 files changed

+34
-3
lines changed

3 files changed

+34
-3
lines changed

lib/presets/custom/angular/deliver/prebuild.js

+32-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
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';
24

35
const packageManager = await getPackageManager();
46

@@ -18,11 +20,39 @@ async function prebuild() {
1820

1921
Manifest.setRoute({
2022
from: '/',
21-
to: '.edge/storage',
23+
to: path.join('.edge', 'storage'),
2224
priority: 1,
2325
type: 'deliver',
2426
});
2527
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+
}
2656
}
2757

2858
export default prebuild;

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
"events": "^3.3.0",
6363
"fast-glob": "^3.3.1",
6464
"form-data": "^4.0.0",
65+
"fs-extra": "^11.2.0",
6566
"https-browserify": "^1.0.0",
6667
"inquirer": "^9.2.7",
6768
"install": "^0.13.0",

yarn.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -4268,7 +4268,7 @@ fs-extra@^10.1.0:
42684268
jsonfile "^6.0.1"
42694269
universalify "^2.0.0"
42704270

4271-
fs-extra@^11.0.0:
4271+
fs-extra@^11.0.0, fs-extra@^11.2.0:
42724272
version "11.2.0"
42734273
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-11.2.0.tgz#e70e17dfad64232287d01929399e0ea7c86b0e5b"
42744274
integrity sha512-PmDi3uwK5nFuXh7XDTlVnS17xJS7vW36is2+w3xcv8SVxiB4NyATf4ctkVY5bkSjX0Y4nbvZCq1/EjtEyr9ktw==

0 commit comments

Comments
 (0)