forked from shakacode/react-webpack-rails-tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.rails.config.js
28 lines (24 loc) · 1.16 KB
/
webpack.rails.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Run like this:
// cd webpack && $(npm bin)/webpack -w --config webpack.rails.config.js
// Note that Foreman (Procfile.dev) has also been configured to take care of this.
// NOTE: All style sheets handled by the asset pipeline in rails
var config = require("./webpack.common.config");
config.entry.push("./scripts/rails_only"); // rails specific assets
config.output = { filename: "webpack-bundle.js",
path: "../app/assets/javascripts" };
config.externals = { jquery: "var jQuery" }; // load jQuery from cdn or rails asset pipeline
config.module.loaders.push(
{ test: /\.jsx$/, loaders: ["es6", "jsx?harmony"] },
// Next 2 lines expose jQuery and $ to any JavaScript files loaded after webpack-bundle.js
// in the Rails Asset Pipeline. Thus, load this one prior.
{ test: require.resolve("jquery"), loader: "expose?jQuery" },
{ test: require.resolve("jquery"), loader: "expose?$" }
);
module.exports = config;
var devBuild = (typeof process.env["BUILDPACK_URL"]) === "undefined";
if (devBuild) {
console.log("Webpack dev build for Rails");
module.exports.devtool = "eval-source-map";
} else {
console.log("Webpack production build for Rails");
}