-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdevServer.js
39 lines (32 loc) · 1.04 KB
/
devServer.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
const path = require('path');
const express = require('express');
const webpack = require('webpack');
const config = require('./webpack.config.dev');
const app = express();
const compiler = webpack(config);
const host = 'http://localhost';
const port = process.env.npm_config_port ? process.env.npm_config_port : 3000;
app.use(require('webpack-dev-middleware')(compiler, {
noInfo: true,
publicPath: config.output.publicPath
}));
app.use(require('webpack-hot-middleware')(compiler));
app.get('*', (req, res) => {
res.sendFile(path.join(__dirname, 'index.html'));
});
app.listen(port, 'localhost', (err) => {
if (err) {
console.log(err);
return;
}
console.info('==> Listening on port %s. Open up %s:%s/ in your browser.', port, host, port);
});
var jsonServer = require('json-server');
var server = jsonServer.create()
var router = jsonServer.router('./test_data/surveyForm1.json')
var middlewares = jsonServer.defaults()
server.use(middlewares)
server.use(router)
server.listen(3004, function () {
console.log('JSON Server is running')
})