Created
January 17, 2017 20:02
-
-
Save moizhb/5be2fd828bfce60a0902db90ab58161b 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
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); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment