mirror of
https://gitlab.com/timvisee/send.git
synced 2025-12-06 14:10:53 +03:00
load android ui in dev when browsing to /android (#919)
This commit is contained in:
committed by
Donovan Preston
parent
041c8ffdd2
commit
17ee4e0058
@@ -1,3 +1,5 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const assets = require('../../common/assets');
|
||||
const locales = require('../../common/locales');
|
||||
const routes = require('../routes');
|
||||
@@ -8,6 +10,11 @@ const expressWs = require('express-ws');
|
||||
const morgan = require('morgan');
|
||||
const config = require('../config');
|
||||
|
||||
const androidIndex = fs.readFileSync(
|
||||
path.resolve(__dirname, '../../android/app/src/main/assets/index.html'),
|
||||
'utf8'
|
||||
);
|
||||
|
||||
module.exports = function(app, devServer) {
|
||||
const wsapp = express();
|
||||
expressWs(wsapp, null, { perMessageDeflate: false });
|
||||
@@ -19,6 +26,15 @@ module.exports = function(app, devServer) {
|
||||
app.use(morgan('dev', { stream: process.stderr }));
|
||||
routes(app);
|
||||
tests(app);
|
||||
app.get('/android', function(req, res) {
|
||||
res.set('Content-Type', 'text/html');
|
||||
res.send(
|
||||
androidIndex
|
||||
.replace('index.css', '/android_asset/index.css')
|
||||
.replace('vendor.js', assets.get('vendor.js'))
|
||||
.replace('android.js', assets.get('android.js'))
|
||||
);
|
||||
});
|
||||
// webpack-dev-server routes haven't been added yet
|
||||
// so wait for next tick to add 404 handler
|
||||
process.nextTick(() => app.use(pages.notfound));
|
||||
|
||||
Reference in New Issue
Block a user