-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev-server.js
More file actions
55 lines (46 loc) · 1.56 KB
/
Copy pathdev-server.js
File metadata and controls
55 lines (46 loc) · 1.56 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
const express = require('express');
var path = require('path');
const webpack = require('webpack');
const webpackDevMiddleware = require('webpack-dev-middleware');
const app = express();
const config = require('./webpack.config.dev.hot.js');
const compiler = webpack(config);
// var index = require('./routes/index');
// const historyApiFallback = require('connect-history-api-fallback');
// app.use(historyApiFallback({
// verbose: false
// }));
// Tell express to use the webpack-dev-middleware and use the webpack.config.dev.hot.js
// configuration file as a base.
app.use(webpackDevMiddleware(compiler, {
publicPath: config.output.publicPath,
stats: {colors: true}
}));
app.use(require('webpack-hot-middleware')(compiler, {
log: console.log
}));
// app.use('/public', express.static('public'));
app.get('*', function(req, res) {
res.sendFile(path.join(__dirname, 'main.html'));
});
// app.get('main.*.bundle.js', function(req, res){
// res.write(webpackDevMiddleware.fileSystem.readFileSync(req.url));
// res.end();
// });
// app.get('*', function(req, res){
// res.write(webpackDevMiddleware.fileSystem.readFileSync(path.join(__dirname, 'main.html')));
// res.end();
// });
// view engine setup
// app.set('views', __dirname);
// app.set('view engine', 'html');
// app.engine('.html', require('ejs').__express);
// app.use('/', index);
// app.use(express.static(__dirname));
// app.use(express.static(__dirname, {
// index: 'main.html'
// }));
// Serve the files on port 3000.
app.listen(3007, function () {
console.log('Example app listening on port 3007!\n');
});