forked from centreon-archive/centreon-archived
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.dev.js
More file actions
63 lines (52 loc) · 1.76 KB
/
webpack.config.dev.js
File metadata and controls
63 lines (52 loc) · 1.76 KB
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
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,
}
: {};
module.exports = merge(baseConfig, devConfig, {
output,
resolve: {
alias: {
'react-router-dom': path.resolve('./node_modules/react-router-dom'),
'@material-ui/core': path.resolve('./node_modules/@material-ui/core'),
dayjs: path.resolve('./node_modules/dayjs'),
},
},
devServer: {
contentBase: [
path.resolve(`${__dirname}/www/modules/centreon-license-manager/static`),
path.resolve(
`${__dirname}/www/modules/centreon-autodiscovery-server/static`,
),
path.resolve(`${__dirname}/www/modules/centreon-bam-server/static`),
],
compress: true,
host: '0.0.0.0',
port: devServerPort,
hot: true,
watchContentBase: true,
headers: { 'Access-Control-Allow-Origin': '*' },
publicPath,
},
plugins,
});