2018-10-02 22:15:02 +02:00
|
|
|
let server = null;
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
onPrepare: function() {
|
|
|
|
return new Promise(function(resolve) {
|
|
|
|
const webpack = require('webpack');
|
|
|
|
const middleware = require('webpack-dev-middleware');
|
|
|
|
const express = require('express');
|
2019-08-06 23:12:22 +02:00
|
|
|
const expressWs = require('@dannycoates/express-ws');
|
2018-10-02 22:15:02 +02:00
|
|
|
const assets = require('../common/assets');
|
|
|
|
const routes = require('../server/routes');
|
|
|
|
const tests = require('./frontend/routes');
|
|
|
|
const app = express();
|
|
|
|
const config = require('../webpack.config');
|
|
|
|
const wpm = middleware(webpack(config(null, { mode: 'development' })), {
|
|
|
|
logLevel: 'silent'
|
|
|
|
});
|
|
|
|
app.use(wpm);
|
|
|
|
assets.setMiddleware(wpm);
|
|
|
|
expressWs(app, null, { perMessageDeflate: false });
|
|
|
|
routes(app);
|
2019-08-02 20:26:52 +02:00
|
|
|
app.ws('/api/ws', require('../server/routes/ws'));
|
2018-10-02 22:15:02 +02:00
|
|
|
tests(app);
|
|
|
|
wpm.waitUntilValid(() => {
|
|
|
|
server = app.listen(8000, resolve);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
onComplete: function() {
|
|
|
|
server.close();
|
|
|
|
}
|
|
|
|
};
|