-
-
Save maman/8e91e6cb4ca9feaa4290 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
/*eslint-disable */ | |
var path = require('path'); | |
var express = require('express'); | |
var webpack = require('webpack'); | |
var config = require(path.join(__dirname, 'webpack.config')); | |
var app = this.app = new express(); | |
var compiler = webpack(config); | |
var devMiddleware = require('webpack-dev-middleware')(compiler, { | |
noInfo: true, | |
publicPath: config.output.publicPath | |
}) | |
/*eslint-enable */ | |
app.use(this.middleware = devMiddleware); | |
app.use(require('webpack-hot-middleware')(compiler)); | |
app.get('*', function(req, res) { | |
/*eslint-disable */ | |
var index = this.middleware.fileSystem.readFileSync(path.join(config.output.path, 'index.html')); | |
/*eslint-enable */ | |
res.end(index); | |
}.bind(this)); | |
app.listen(3001, 'localhost', function(err) { | |
if (err) { | |
console.log('err'); | |
return; | |
} | |
console.log('Listening at http://localhost:3001'); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Better yet, put this in your webpack config and use with webpack-dev-server