forked from remix-run/react-router
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
29 lines (23 loc) · 782 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
/*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'))
})
app.use(express.static(__dirname))
app.listen(8080, function () {
console.log('Server listening on http://localhost:8080, Ctrl+C to stop')
})