-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
executable file
·35 lines (27 loc) · 953 Bytes
/
server.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
/*eslint-disable no-console, no-var */
var express = require('express')
var rewrite = require('express-urlrewrite')
var webpack = require('webpack')
var webpackDevMiddleware = require('webpack-dev-middleware')
var WebpackConfig = require('./webpack.config')
var app = express()
app.use(webpackDevMiddleware(webpack(WebpackConfig), {
publicPath: '/__build__/',
stats: {
colors: true
}
}))
var fs = require('fs')
var path = require('path')
// fs.readdirSync(__dirname).forEach(function (file) {
// if (fs.statSync(path.join(__dirname, file)).isDirectory())
// app.use(rewrite('/' + file + '/*', '/' + file + '/index.html'))
// })
console.log(fs.readdirSync(__dirname), path.join(__dirname ));
app.get('/', function(req, res) {
res.sendFile(path.join(__dirname + '/index.html'));
});
app.use(express.static(__dirname))
app.listen(8080, function () {
console.log('Server listening on http://localhost:8080, Ctrl+C to stop')
})