Skip to content

Instantly share code, notes, and snippets.

@markmur
Created April 11, 2016 23:07
Show Gist options
  • Save markmur/c246525f30445bc33170688aaf231870 to your computer and use it in GitHub Desktop.
Save markmur/c246525f30445bc33170688aaf231870 to your computer and use it in GitHub Desktop.
Webpack Hot Reload
<script src="/static/bundle.js"></script>
var webpack = require('webpack');
var WebpackDevServer = require('webpack-dev-server');
var config = require('./webpack.config');
new WebpackDevServer(webpack(config), {
hot: true,
colors: true,
publicPath: config.output.publicPath,
historyApiFallback: true,
}).listen(3000, 'localhost', function (err, result) {
if (err) {
return console.log(err);
}
console.log('Listening at http://localhost:3000/');
});
var path = require('path');
var webpack = require('webpack');
module.exports = {
devtool: 'eval',
entry: [
'webpack-dev-server/client?http://localhost:3000',
'webpack/hot/only-dev-server',
'./js/main.v2'
],
output: {
path: path.join(__dirname, 'dist'),
filename: 'bundle.js',
publicPath: '/static/'
},
plugins: [
new webpack.HotModuleReplacementPlugin()
],
module: {
loaders: [{
test: /\.js$/,
loaders: ['babel'],
exclude: /node_modules/
},
{
test: /\.scss$/,
loaders: ["style", "css", "sass"]
}]
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment