forked from dimasmith/together
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdevProxy.js
More file actions
41 lines (34 loc) · 1005 Bytes
/
devProxy.js
File metadata and controls
41 lines (34 loc) · 1005 Bytes
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
/**
* Development server proxy
* @type {module.exports}
*/
import webpack from 'webpack';
import WebpackDevServer from 'webpack-dev-server';
import webpackConfig from './webpack/frontend.dev';
import path from 'path';
const publicPath = '/';
const contentBase = path.join(__dirname, 'dist');
function start(config) {
if (config.development) {
// Development mode
// Start webpack dev server as proxy for main server
const compiler = webpack(webpackConfig);
const serverUrl = `http://${config.host}:${config.port}`;
const devServer = new WebpackDevServer(compiler, {
contentBase,
publicPath,
filename: 'client.bundle.js',
inline: true,
quiet: false,
noInfo: true,
stats: {colors: true},
proxy: {
'/photos/*': serverUrl,
},
});
devServer.listen(config.proxyPort, config.host, function() {
console.info('Dev server started in proxy mode on', config.proxyPort);
});
}
}
module.exports = start;