-
Notifications
You must be signed in to change notification settings - Fork 96
/
electron-builder-hooks.ts
62 lines (56 loc) · 1.73 KB
/
electron-builder-hooks.ts
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
import nodeExternals from "webpack-node-externals";
import path from "path";
import {Configuration} from "webpack";
import {LoaderConfig as TsLoaderConfig} from "awesome-typescript-loader/src/interfaces";
import {buildBaseConfig, rootRelativePath} from "./lib";
const hooksDir = (...value: string[]) => path.join(
rootRelativePath("./scripts/electron-builder/hooks"),
...value,
);
// TODO scan folder automatically
const hooksToBuild = [
// "afterAllArtifactBuild",
"afterPack",
];
const configurations: Configuration[] = hooksToBuild.map((hookDirName) => {
const hookDir = path.join(hooksDir(hookDirName));
const tsConfigFile = path.join(hookDir, "tsconfig.json");
return buildBaseConfig(
{
mode: "none",
devtool: false,
target: "node",
entry: {
index: hookDir,
},
output: {
path: hookDir,
...{
// https://github.com/webpack/webpack/issues/2030#issuecomment-232886608
library: "",
libraryTarget: "commonjs",
},
},
module: {
rules: [
{
test: /\.ts$/,
use: {
loader: "awesome-typescript-loader",
options: {
configFileName: tsConfigFile,
} as TsLoaderConfig,
},
},
],
},
externals: [
nodeExternals(),
],
},
{
tsConfigFile,
},
);
});
export default configurations;