forked from shakacode/react-webpack-rails-tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver-rails-hot.js
47 lines (37 loc) · 1.18 KB
/
server-rails-hot.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
/* eslint no-var: 0, no-console: 0, import/no-extraneous-dependencies: 0 */
import webpack from 'webpack';
import WebpackDevServer from 'webpack-dev-server';
import webpackConfig from './webpack.client.rails.hot.config';
const { resolve } = require('path');
const webpackConfigLoader = require('react-on-rails/webpackConfigLoader');
const configPath = resolve('..', 'config');
const { output, settings } = webpackConfigLoader(configPath);
const hotReloadingUrl = output.publicPathWithHost;
const hotReloadingPort = settings.dev_server.port;
const hotReloadingHostname = settings.dev_server.host;
const compiler = webpack(webpackConfig);
const devServer = new WebpackDevServer(compiler, {
proxy: {
'*': `http://lvh.me:${hotReloadingPort}`,
},
contentBase: hotReloadingUrl,
hot: true,
inline: true,
historyApiFallback: true,
quiet: false,
noInfo: false,
lazy: false,
stats: {
colors: true,
hash: false,
version: false,
chunks: false,
children: false,
},
});
devServer.listen(hotReloadingPort, hotReloadingHostname, (err) => {
if (err) console.error(err);
console.log(
`=> 🔥 Webpack development server is running on ${hotReloadingUrl}`,
);
});