Created
January 14, 2016 08:22
-
-
Save Darkside73/e3b70d72443e0f72b27b to your computer and use it in GitHub Desktop.
Webpack dev server with hot reload
This file contains hidden or 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
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