forked from shakacode/react-webpack-rails-tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.client.express.config.js
110 lines (99 loc) · 2.34 KB
/
webpack.client.express.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/* eslint comma-dangle: ["error",
{"functions": "never", "arrays": "only-multiline", "objects": "only-multiline"} ] */
// Run like this:
// cd client && node server-express.js
const webpack = require('webpack');
const config = require('./webpack.client.base.config');
const hotPort = process.env.HOT_PORT || 4000;
config.entry.vendor.push('bootstrap-loader');
config.entry.app.push(
// Shouldn't be necessary:
// https://github.com/shakacode/react_on_rails/issues/504
'./app/bundles/comments/startup/ClientRouterAppExpress',
// Webpack dev server
`webpack-dev-server/client?http://localhost:${hotPort}`,
'webpack/hot/dev-server'
);
config.output = {
// this file is served directly by webpack
filename: '[name].js',
path: __dirname,
};
config.plugins.unshift(
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin()
);
config.devtool = 'eval-source-map';
// All the styling loaders only apply to hot-reload, not rails
config.module.rules.push(
{
test: /\.jsx?$/,
loader: 'babel-loader',
exclude: /node_modules/,
query: {
plugins: [
[
'react-transform',
{
superClasses: ['React.Component', 'BaseComponent', 'Component'],
transforms: [
{
transform: 'react-transform-hmr',
imports: ['react'],
locals: ['module'],
},
],
},
],
],
},
},
{
test: /\.css$/,
use: [
{
loader: 'css-loader',
options: {
modules: true,
importLoaders: 0,
localIdentName: '[name]__[local]__[hash:base64:5]'
}
},
{
loader: 'postcss-loader',
options: {
plugins: 'autoprefixer'
}
}
]
},
{
test: /\.scss$/,
use: [
{
loader: 'css-loader',
options: {
modules: true,
importLoaders: 3,
localIdentName: '[name]__[local]__[hash:base64:5]',
}
},
{
loader: 'postcss-loader',
options: {
plugins: 'autoprefixer'
}
},
{
loader: 'sass-loader'
},
{
loader: 'sass-resources-loader',
options: {
resources: './app/assets/styles/app-variables.scss'
},
}
],
}
);
module.exports = config;