Skip to content

Instantly share code, notes, and snippets.

@gaearon
Created December 14, 2014 17:49
Show Gist options
  • Save gaearon/15bbedb69c204d7fc318 to your computer and use it in GitHub Desktop.
Save gaearon/15bbedb69c204d7fc318 to your computer and use it in GitHub Desktop.
WebpackDevServer + pushState hook
server = new WebpackDevServer(webpack(config), {
contentBase: contentBase,
publicPath: config.output.publicPath,
hot: true
});
server.listen(port, '0.0.0.0');
server.app.use(function pushStateHook(req, res, next) {
var ext = path.extname(req.url);
if ((ext === '' || ext === '.html') && req.url !== '/') {
req.pipe(request(localURL)).pipe(res);
} else {
next();
}
});
Copy link

ghost commented Aug 30, 2016

What are path and request variables? Can you provide imports if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment