Skip to content

Commit 790f21d

Browse files
committed
Use react-hot webpack loader only in dev environment
1 parent d7e07b2 commit 790f21d

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

webpack/webpack.common.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ module.exports = {
1818
module: {
1919
loaders: [
2020
{ test: require.resolve("react"), loader: "expose?React" },
21-
{ test: /\.jsx$/, loaders: ["react-hot", "es6", "jsx?harmony"] },
2221
{ test: /\.css$/, loader: "style-loader!css-loader" },
2322
{ test: /\.scss$/, loader: "style!css!sass?outputStyle=expanded&imagePath=/assets/images"},
2423

webpack/webpack.hot.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ config.entry.push("webpack-dev-server/client?http://localhost:3000",
1212
"bootstrap-sass!./bootstrap-sass.config.js"); // custom bootstrap
1313
config.output = { filename: "express-bundle.js", // this file is served directly by webpack
1414
path: __dirname };
15+
config.module.loaders.push(
16+
{ test: /\.jsx$/, loaders: ["react-hot", "es6", "jsx?harmony"] },
17+
);
1518
config.plugins = [ new webpack.HotModuleReplacementPlugin() ];
1619
config.devtool = "eval-source-map";
1720
module.exports = config;

webpack/webpack.rails.config.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,26 @@ config.output = { filename: "webpack-bundle.js",
99
path: "../app/assets/javascripts" };
1010
config.externals = { jquery: "var jQuery" }; // load jQuery from cdn or rails asset pipeline
1111
config.module.loaders.push(
12+
{ test: /\.jsx$/, loaders: ["es6", "jsx?harmony"] },
1213
{ test: /\.scss$/, loader: "style!css!sass?outputStyle=expanded&imagePath=/assets/images"},
1314
// Next 2 lines expose jQuery and $ to any JavaScript files loaded after webpack-bundle.js
1415
// in the Rails Asset Pipeline. Thus, load this one prior.
1516
{ test: require.resolve("jquery"), loader: "expose?jQuery" },
1617
{ test: require.resolve("jquery"), loader: "expose?$" }
1718
);
18-
module.exports = config;
1919

2020
var devBuild = (typeof process.env["BUILDPACK_URL"]) === "undefined";
2121
if (devBuild) {
2222
console.log("Webpack dev build for Rails");
23-
module.exports.devtool = "eval-source-map";
23+
config.module.loaders.push(
24+
{ test: /\.jsx$/, loaders: ["react-hot", "es6", "jsx?harmony"] }
25+
);
26+
config.devtool = "eval-source-map";
2427
} else {
2528
console.log("Webpack production build for Rails");
29+
config.module.loaders.push(
30+
{ test: /\.jsx$/, loaders: ["es6", "jsx?harmony"] }
31+
);
2632
}
33+
34+
module.exports = config;

0 commit comments

Comments
 (0)