-
-
Save bretthadley/3176bc84ee30a5f45fa4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import path from 'path'; | |
import express from 'express'; | |
import webpack from 'webpack'; | |
import webpackDevMiddleware from 'webpack-dev-middleware'; | |
import webpackHotMiddleware from 'webpack-hot-middleware'; | |
import appConfig from '../tools/config'; | |
const app = express(); | |
const port = 3000; | |
const compiler = webpack(appConfig); | |
app.use(webpackDevMiddleware(compiler, { noInfo: true, lazy: false, publicPath: appConfig.output.publicPath })); | |
app.use(webpackHotMiddleware(compiler)); | |
app.use(express.static(path.join(__dirname, 'public'))); | |
app.use(function(req, res) { | |
res.sendFile(__dirname + '/public/index.html') | |
}); | |
const server = app.listen(port, function (err) { | |
if(err) { | |
console.log('Error'); | |
} else { | |
let port = server.address().port; | |
let host = server.address().address; | |
console.log('Listening at http://%s:%s', host, port); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment