forked from lexogrine/csgo-react-hud
-
Notifications
You must be signed in to change notification settings - Fork 0
/
craco.config.js
45 lines (37 loc) · 1.15 KB
/
craco.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
const path = require('path');
const fs = require('fs');
const homedir = require('os').homedir();
const internalIp = require('internal-ip');
const OpenBrowserPlugin = require('./OpenBrowserPlugin');
const pathToConfig = path.join(process.env.APPDATA || path.join(homedir, '.config'), 'hud-manager', 'databases', 'config');
let port = 1349;
const getPort = () => {
if(!fs.existsSync(pathToConfig)){
console.warn('LHM Config file unavailable');
return port;
}
try {
const config = JSON.parse(fs.readFileSync(pathToConfig, 'utf-8'));
if(!config.port){
console.warn('LHM Port unavailable');
}
console.warn('LHM Port detected as', config.port);
return config.port;
} catch {
console.warn('LHM Config file invalid');
return port;
}
}
port = getPort();
module.exports = {
devServer: {
port: 3500,
open: false
},
webpack: {
configure: (webpackConfig) => {
webpackConfig.plugins.push(new OpenBrowserPlugin({ url: `http://${internalIp.v4.sync()}:${port}/development/`}))
return webpackConfig;
}
}
};