Skip to content

Instantly share code, notes, and snippets.

@justin808
Created September 16, 2014 19:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justin808/9ced59d3dd3f50d3e5be to your computer and use it in GitHub Desktop.
Save justin808/9ced59d3dd3f50d3e5be to your computer and use it in GitHub Desktop.
Sample file for testing webpack bundled assets when used in the context of Rails. See https://github.com/justin808/react-webpack-rails-tutorial for more details.
var webpack = require("webpack");
var path = require("path");
module.exports = {
devtool: "source-map",
context: __dirname, // + "/../app/assets/javascripts",
entry: [
"webpack-dev-server/client?http://localhost:3000",
"webpack/hot/dev-server",
"./scripts/webpack_only",
"./assets/javascripts/example"
],
// Note, this file is not actually saved, but used by the express server
output: {
filename: "express-bundle.js",
path: __dirname
},
plugins: [
new webpack.HotModuleReplacementPlugin()
],
// Let's load jQuery from the CDN
externals: {
jquery: "var jQuery"
},
resolve: {
root: [ path.join(__dirname, "scripts"), path.join(__dirname, "assets/javascripts"),
path.join(__dirname, "assets/stylesheets") ],
extensions: ["", ".webpack.js", ".web.js", ".js", ".jsx", ".scss", ".css", "config.js"]
},
module: {
loaders: [
{ test: require.resolve("react"), loader: "expose?React" },
{ test: /\.jsx$/, loaders: ["react-hot", "es6", "jsx?harmony"] },
{ test: /\.css$/, loader: "style-loader!css-loader" },
{ test: /\.scss$/, loader: "style!css!sass?outputStyle=expanded&imagePath=/assets/images"}
]
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment