Created
June 12, 2015 00:11
-
-
Save craigbeck/a641c20c420ffa977099 to your computer and use it in GitHub Desktop.
Hot reload webpack configuration
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 path = require("path"); | |
var util = require("util"); | |
var host = process.env.HOST || "localhost"; | |
var port = process.env.PORT || 8080; | |
module.exports = { | |
entry: { | |
app: [ | |
"webpack/hot/only-dev-server", | |
"./app/main.jsx" | |
], | |
widget: [ | |
"./app/widget.jsx" | |
] | |
}, | |
output: { | |
path: path.resolve(__dirname, "public", "dist", "js"), | |
publicPath: util.format("http://%s:%s/", host, port), | |
filename: "[name].bundle.js", | |
chunkFilename: "[name]-[id].bundle.js" | |
}, | |
module: { | |
loaders: [{ | |
test: /\.jsx$/, | |
loaders: ["react-hot", "babel-loader"], | |
exclude: path.resolve(__dirname, "node_modules") | |
}, { | |
test: /\.json$/, | |
loader: "json-loader" | |
}, { | |
test: /\.scss$/, | |
loader: "style!css!sass" | |
}, | |
// Needed for the css-loader when [bootstrap-webpack](https://github.com/bline/bootstrap-webpack) | |
// loads bootstrap's css. | |
{ test: /\.woff2?(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&minetype=application/font-woff" }, | |
{ test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&minetype=application/octet-stream" }, | |
{ test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, loader: "file" }, | |
{ test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&minetype=image/svg+xml" } | |
] | |
}, | |
resolve: { | |
extensions: ["", ".js", ".jsx"], | |
alias: { | |
pubnub: path.resolve(__dirname, "./lib/pubnub") | |
} | |
}, | |
devServer: { | |
contentBase: path.resolve(__dirname, "public"), | |
devtool: "eval", | |
progress: true, | |
colors: true, | |
hot: true, | |
host: "0.0.0.0", | |
port: port, | |
proxy: { | |
"*": util.format("http://%s:8081", host) | |
} | |
}, | |
plugins: [ | |
new Webpack.HotModuleReplacementPlugin(), | |
new Webpack.NoErrorsPlugin() | |
] | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment