Skip to content

Instantly share code, notes, and snippets.

@alexfedoseev
Last active Aug 29, 2015
Embed
What would you like to do?
Webpack development server with hot reloading: iteration 1
/* server.dev.js */
require('babel/register')({
extensions: ['.js', '.jsx'],
stage : 0
});
var webpack = require('webpack');
var WebpackDevServer = require('webpack-dev-server');
var webpackConfig = require('./build/webpack.config.dev');
var serverConfig = require('./config/server');
var initialCompile = true;
var compiler = webpack(webpackConfig);
var devServer = new WebpackDevServer(compiler, {
contentBase : 'http://lvh.me:' + serverConfig.devPort,
publicPath : webpackConfig.output.publicPath,
hot : true,
inline : true,
historyApiFallback: true,
quiet : false,
noInfo : false,
lazy : false,
stats : {
colors : true,
hash : false,
version : false,
chunks : false,
children: false
}
});
devServer.listen(serverConfig.devPort, 'localhost', function(err) {
if (err) console.error(err);
console.log('=> 🔥 Webpack development server is running on port %s', serverConfig.devPort);
});
// This part will notify gulp that assets are compiled
// Gulp will start application Express server then
// (and it'll pick up assets filenames from json manifest to inject them in html)
compiler.plugin('done', function() {
if (initialCompile) {
initialCompile = false;
process.stdout.write('Webpack: Done!');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment