bonzai-tools 1.0.98 → 1.0.99
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -14,15 +14,34 @@ const server = http.createServer(app);
|
|
|
14
14
|
app.use(cors());
|
|
15
15
|
app.use(express.json());
|
|
16
16
|
|
|
17
|
-
//
|
|
17
|
+
// Serve static build files
|
|
18
|
+
const buildDir = path.join(__dirname, 'build');
|
|
19
|
+
app.use('/static', express.static(path.join(buildDir, 'static')));
|
|
20
|
+
|
|
21
|
+
// Embed shell - serves HTML that loads bundled app
|
|
18
22
|
app.get('/', (req, res) => {
|
|
19
23
|
const repoName = path.basename(ROOT);
|
|
24
|
+
|
|
25
|
+
// Read asset manifest to get hashed filenames
|
|
26
|
+
const manifestPath = path.join(buildDir, 'asset-manifest.json');
|
|
27
|
+
let cssFile = '';
|
|
28
|
+
let jsFile = '';
|
|
29
|
+
|
|
30
|
+
try {
|
|
31
|
+
const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
|
|
32
|
+
cssFile = manifest.files['main.css'] || '';
|
|
33
|
+
jsFile = manifest.files['main.js'] || '';
|
|
34
|
+
} catch (e) {
|
|
35
|
+
console.error('Could not read asset-manifest.json:', e.message);
|
|
36
|
+
}
|
|
37
|
+
|
|
20
38
|
res.send(`<!DOCTYPE html>
|
|
21
39
|
<html>
|
|
22
40
|
<head>
|
|
23
41
|
<meta charset="UTF-8">
|
|
24
42
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
25
43
|
<title>Bonzai - ${repoName}</title>
|
|
44
|
+
${cssFile ? `<link rel="stylesheet" href="${cssFile}">` : ''}
|
|
26
45
|
<style>
|
|
27
46
|
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
28
47
|
html, body, #root { height: 100%; }
|
|
@@ -34,7 +53,7 @@ app.get('/', (req, res) => {
|
|
|
34
53
|
window.BONZAI_REPO = "${repoName}";
|
|
35
54
|
window.BONZAI_API = "http://localhost:${port}";
|
|
36
55
|
</script>
|
|
37
|
-
|
|
56
|
+
${jsFile ? `<script src="${jsFile}"></script>` : '<p>Build not found. Run npm run build in the frontend.</p>'}
|
|
38
57
|
</body>
|
|
39
58
|
</html>`);
|
|
40
59
|
});
|