This repository has been archived by the owner on Sep 14, 2023. It is now read-only.
forked from shakacode/react_on_rails
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.client.rails.hot.config.js
79 lines (69 loc) · 1.72 KB
/
webpack.client.rails.hot.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// Run with Rails server like this:
// rails s
// cd client && babel-node server-rails-hot.js
// Note that Foreman (Procfile.dev) has also been configured to take care of this.
const path = require('path');
const webpack = require('webpack');
const config = require('./webpack.client.base.config');
const hotRailsPort = process.env.HOT_RAILS_PORT || 3500;
config.entry.app.push(
`webpack-dev-server/client?http://localhost:${hotRailsPort}`,
'webpack/hot/only-dev-server'
);
config.output = {
filename: '[name]-bundle.js',
path: path.join(__dirname, 'public'),
publicPath: `http://localhost:${hotRailsPort}/`,
};
config.module.loaders.push(
{
test: /\.jsx?$/,
loader: 'babel',
exclude: /node_modules/,
query: {
plugins: [
[
'react-transform',
{
transforms: [
{
transform: 'react-transform-hmr',
imports: ['react'],
locals: ['module'],
},
],
},
],
],
},
},
{
test: /\.css$/,
loaders: [
'style',
'css?modules&importLoaders=1&localIdentName=[name]__[local]__[hash:base64:5]',
'postcss',
],
},
{
test: /\.scss$/,
loaders: [
'style',
'css?modules&importLoaders=3&localIdentName=[name]__[local]__[hash:base64:5]',
'postcss',
'sass',
'sass-resources',
],
},
{
test: require.resolve('jquery-ujs'),
loader: 'imports?jQuery=jquery',
}
);
config.plugins.push(
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin()
);
config.devtool = 'eval-source-map';
console.log('Webpack HOT dev build for Rails'); // eslint-disable-line no-console
module.exports = config;