Skip to content

Instantly share code, notes, and snippets.

@Darkside73
Created January 14, 2016 08:22
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Darkside73/e3b70d72443e0f72b27b to your computer and use it in GitHub Desktop.
Save Darkside73/e3b70d72443e0f72b27b to your computer and use it in GitHub Desktop.
Webpack dev server with hot reload
const webpack = require('webpack');
const WebpackDevServer = require('webpack-dev-server');
const config = require('../webpack.config');
const hotWebpackPort = process.env.HOT_WEBPACK_PORT || 3500;
config.output.publicPath = `https://localhost:${hotWebpackPort}/assets/`;
['entry1', 'entry2'].forEach(entryName => {
config.entry[entryName].push(
'webpack-dev-server/client?https://localhost:' + hotWebpackPort,
'webpack/hot/only-dev-server'
);
});
config.plugins.push(
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin()
);
new WebpackDevServer(webpack(config), {
publicPath: config.output.publicPath,
hot: true,
inline: true,
historyApiFallback: true,
quiet: false,
noInfo: false,
lazy: false,
https: true,
stats: {
colors: true,
hash: false,
version: false,
chunks: false,
children: false,
}
}).listen(hotWebpackPort, 'localhost', function (err, result) {
if (err) console.log(err)
console.log(
'=> 🔥 Webpack development server is running on port ' + hotWebpackPort
);
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment