-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
118 lines (109 loc) · 2.49 KB
/
webpack.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/* eslint-disable no-undef */
/* eslint-disable @typescript-eslint/no-var-requires */
const path = require("path");
const webpack = require("webpack");
const package = require('./package.json')
const config = {
mode: "development",
output: {
path: path.resolve(__dirname, "dist/electron-workspace"),
filename: "[name].js"
},
resolve: {
extensions: [".tsx", ".ts", ".js", ".json"],
},
module: {
rules: [
{ test: /\.node$/, loader: "native-ext-loader" },
{ test: /\.tsx?$/, use: ["ts-loader"], exclude: /node_modules/ }
]
}
};
const mainConfig = {
...config,
name: "main-dev",
entry: {
main: "./src/main/index.ts",
},
plugins: [
new webpack.DefinePlugin({
DIST: false,
VERSION: JSON.stringify(package.version),
APP_ID: JSON.stringify(package.appId)
})
],
node: {
__dirname: false
},
target: "electron-main"
};
const mainConfigDist = {
...config,
mode: "production",
name: "main-dist",
entry: {
main: "./src/main/index.ts",
},
plugins: [
new webpack.DefinePlugin({
DIST: true,
VERSION: JSON.stringify(package.version),
APP_ID: JSON.stringify(package.appId)
})
],
node: {
__dirname: false
},
target: "electron-main"
};
const rendererConfig = {
...config,
name: "renderer-dev",
entry: {
renderer: "./src/renderer/index.ts"
},
plugins: [
new webpack.DefinePlugin({
DIST: false,
VERSION: JSON.stringify(package.version),
APP_ID: JSON.stringify(package.appId)
})
],
target: "electron-renderer"
};
const rendererConfigDist = {
...config,
mode: "production",
name: "renderer-dist",
entry: {
renderer: "./src/renderer/index.ts"
},
plugins: [
new webpack.DefinePlugin({
DIST: true,
VERSION: JSON.stringify(package.version),
APP_ID: JSON.stringify(package.appId)
})
],
target: "electron-renderer"
};
const unitTestsConfig = {
...config,
output: {
path: path.resolve(__dirname, "test/bin"),
filename: "[name].js"
},
name: "unitTests",
entry: {
unitTests: "./test/unit/index.ts"
},
plugins: [
new webpack.DefinePlugin({
DIST: false,
VERSION: JSON.stringify(package.version),
APP_ID: JSON.stringify(package.appId)
})
],
target: "node"
};
module.exports = [ mainConfig, mainConfigDist, rendererConfig, rendererConfigDist, unitTestsConfig ];