forked from stake-house/wagyu-key-gen
-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.electron.config.js
88 lines (85 loc) · 2.52 KB
/
webpack.electron.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
"use strict";
const path = require("path");
const webpack = require("webpack");
const { GitRevisionPlugin } = require("git-revision-webpack-plugin");
const gitRevisionPlugin = new GitRevisionPlugin({
branch: true,
commithashCommand: "rev-list --max-count=1 --no-merges --abbrev-commit HEAD",
});
let data = {
VERSION: JSON.stringify(process.env.RELEASE || gitRevisionPlugin.version()),
COMMITHASH: JSON.stringify(gitRevisionPlugin.commithash()),
BRANCH: JSON.stringify(gitRevisionPlugin.branch()),
LASTCOMMITDATETIME: JSON.stringify(gitRevisionPlugin.lastcommitdatetime()),
};
const old = process.cwd();
process.chdir("./src/vendors/tools-key-gen-cli");
try {
const cliGitRevisionPlugin = new GitRevisionPlugin({
commithashCommand:
"rev-list --max-count=1 --no-merges --abbrev-commit HEAD",
versionCommand: "describe --tags",
});
data = {
...data,
CLIVERSION: JSON.stringify(cliGitRevisionPlugin.version()),
CLICOMMITHASH: JSON.stringify(cliGitRevisionPlugin.commithash()),
};
} catch (err) {
const cliGitRevisionPlugin = new GitRevisionPlugin({
commithashCommand:
"rev-list --max-count=1 --no-merges --abbrev-commit HEAD",
versionCommand: "describe --always",
});
data = {
...data,
CLIVERSION: JSON.stringify(cliGitRevisionPlugin.version()),
CLICOMMITHASH: JSON.stringify(cliGitRevisionPlugin.commithash()),
};
}
process.chdir(old);
module.exports = [
{
mode: "development",
entry: "./src/electron/index.ts",
output: {
filename: "index.js",
path: path.resolve(__dirname, "build/electron"),
},
module: {
rules: [{ test: /\.tsx?$/, loader: "ts-loader" }],
},
plugins: [gitRevisionPlugin, new webpack.DefinePlugin(data)],
resolve: {
extensions: [".ts", ".tsx", ".js"],
},
// tell webpack that we're building for electron
target: "electron-main",
node: {
// tell webpack that we actually want a working __dirname value
// (ref: https://webpack.js.org/configuration/node/#node-__dirname)
__dirname: false,
},
},
{
mode: "development",
entry: "./src/electron/preload.ts",
output: {
filename: "preload.js",
path: path.resolve(__dirname, "build/electron"),
},
module: {
rules: [{ test: /\.tsx?$/, loader: "ts-loader" }],
},
resolve: {
extensions: [".ts", ".tsx", ".js"],
alias: {
buffer: path.resolve(
__dirname,
"node_modules/buffer-promisify/index.js"
),
},
},
target: "electron-preload",
},
];