forked from pydt/client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextra-webpack.config.js
More file actions
42 lines (37 loc) · 1.22 KB
/
extra-webpack.config.js
File metadata and controls
42 lines (37 loc) · 1.22 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
var fs = require('fs');
var webpack = require('webpack');
var ENV = process.env.npm_lifecycle_event;
var isProd = ENV === 'build-prod';
var apiUrl = "https://api.playyourdamnturn.com";
if (!isProd) {
try {
apiUrl = fs.readFileSync('../api-dev-url.txt', 'utf-8');
console.log('Using ' + apiUrl + ' for API URL!');
} catch (Error) {
console.log('There wasn\'t anything in ../api-dev-url.txt, using prod api url...');
}
}
var iotCreds = {
accessKey: process.env.IOT_CLIENT_ACCESS_KEY,
secretKey: process.env.IOT_CLIENT_SECRET_KEY
};
if (fs.existsSync("iot-client-creds.json")) {
console.log("Using IoT creds from file...");
iotCreds = JSON.parse(fs.readFileSync("iot-client-creds.json"));
} else {
console.log("Using IoT creds from environment...")
}
module.exports = {
target: 'electron-renderer',
plugins: [
new webpack.DefinePlugin({
// Environment helpers
'PYDT_CONFIG': {
PROD: JSON.stringify(isProd),
API_URL: JSON.stringify(apiUrl),
IOT_CLIENT_ACCESS_KEY: JSON.stringify(iotCreds.accessKey),
IOT_CLIENT_SECRET_KEY: JSON.stringify(iotCreds.secretKey),
}
})
]
};