forked from kduret/centreon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.dev.js
67 lines (54 loc) · 1.74 KB
/
webpack.config.dev.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
const path = require('path');
const os = require('os');
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
const { merge } = require('webpack-merge');
const devConfig = require('@centreon/centreon-frontend/packages/frontend-config/webpack/patch/dev');
const baseConfig = require('./webpack.config');
const devServerPort = 9090;
const interfaces = os.networkInterfaces();
const externalInterface = Object.keys(interfaces).find(
(interfaceName) =>
!interfaceName.includes('docker') &&
interfaces[interfaceName][0].family === 'IPv4' &&
interfaces[interfaceName][0].internal === false,
);
const devServerAddress = externalInterface
? interfaces[externalInterface][0].address
: 'localhost';
const publicPath = `http://${devServerAddress}:${devServerPort}/static/`;
const isServing = process.env.WEBPACK_ENV === 'serve';
const plugins = isServing ? [new ReactRefreshWebpackPlugin()] : [];
const output = isServing
? {
publicPath,
}
: {};
const modules = [
'centreon-license-manager',
'centreon-autodiscovery-server',
'centreon-bam-server',
'centreon-augmented-services',
];
module.exports = merge(baseConfig, devConfig, {
devServer: {
compress: true,
headers: { 'Access-Control-Allow-Origin': '*' },
host: '0.0.0.0',
hot: true,
port: devServerPort,
static: modules.map((module) => ({
directory: path.resolve(`${__dirname}/www/modules/${module}/static`),
publicPath,
watch: true,
})),
},
output,
plugins,
resolve: {
alias: {
'@material-ui/core': path.resolve('./node_modules/@material-ui/core'),
dayjs: path.resolve('./node_modules/dayjs'),
'react-router-dom': path.resolve('./node_modules/react-router-dom'),
},
},
});