Created
April 11, 2016 23:07
-
-
Save markmur/c246525f30445bc33170688aaf231870 to your computer and use it in GitHub Desktop.
Webpack Hot Reload
This file contains 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
<script src="/static/bundle.js"></script> |
This file contains 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
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/'); | |
}); |
This file contains 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
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