From 3755693be0be520deaf92d566f7e5e00d71fdcf5 Mon Sep 17 00:00:00 2001
From: zhoudw <zhoudw@infobird.com>
Date: Mon, 10 Jan 2022 15:50:59 +0800
Subject: [PATCH] 打包

---
 bin/app.js |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/bin/app.js b/bin/app.js
index 68b40f2..8f1ba71 100644
--- a/bin/app.js
+++ b/bin/app.js
@@ -2,6 +2,7 @@
 const { createProxyMiddleware } = require('http-proxy-middleware');
 const app = express();
 const path = require('path');
+const fs = require('fs');
 const config = require(path.join(__dirname, '../dist/config'));
 
 // proxy 中间件的选择项
@@ -59,7 +60,10 @@
 //     // res.sendFile(path.join(__dirname, '../dist/index.html'));
 // });
 app.get('*', function(req, res) {
-    res.sendFile(path.join(__dirname, '../dist/index.html'));
+    const indexPath = config.NODE_ENV == 'production' ? '../dist/prod/index.html' : config.NODE_ENV == 'test' ?
+        '../dist/test/index.html' : '../dist/dev/index.html';
+    const html = fs.readFileSync(path.resolve(__dirname, indexPath), 'utf-8');
+    res.send(html);
 });
 app.listen(config.APP_SERVER_PORT, '0.0.0.0', function(err) {
     if (err) {

--
Gitblit v1.8.0