-
-
Save cef62/955081fd942437a42231 to your computer and use it in GitHub Desktop.
HTML5 API support con webpack-dev-middleware and index.html dynamically generated
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