Created
August 13, 2017 17:18
-
-
Save liondancer/a8209ffb7e1c28d17a448af88585f763 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 express from 'express'; | |
import webpack from 'webpack'; | |
import webpackDevMiddleware from 'webpack-dev-middleware'; | |
import path from 'path'; | |
import config from '../../webpack.config.dev'; | |
import open from 'open'; | |
/* eslint-disable no-console */ | |
const port = 3000; | |
const app = express(); | |
const compiler = webpack(config); | |
// Tell express to use the webpack-dev-middleware and use the webpack.config.dev.js | |
// configuration file as a base. | |
app.use(webpackDevMiddleware(compiler, { | |
publicPath: config.output.publicPath | |
})); | |
app.use(require('webpack-hot-middleware')(compiler)); | |
app.get('*', function(req, res) { | |
res.sendFile(path.join( __dirname, '../index.html')); | |
}); | |
app.listen(port, err => { | |
if (err) { | |
console.log(err); | |
} else { | |
open(`http://localhost:${port}`); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment