-
Notifications
You must be signed in to change notification settings - Fork 24
/
webpack.main.js
58 lines (53 loc) · 1.32 KB
/
webpack.main.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
const path = require('path')
const nodeExternals = require('webpack-node-externals')
const common = (_ /* env */, argv) => ({
output: {
path: path.resolve(__dirname, 'public'),
filename: '[name].js'
},
devtool: argv.mode === 'production' ? false : 'source-map',
resolve: {
extensions: ['.ts', '.js']
},
module: {
rules: [
{
test: [/\.tsx?$/],
loader: 'ts-loader',
options: { configFile: path.resolve(__dirname, 'tsconfig.main.json') },
exclude: /node_modules/
}
]
},
node: {
__dirname: false,
__filename: false
},
// Add `node-hid` to externals build issues
// https://webpack.js.org/configuration/externals/#root
// Note: ^ Disabled temporary due sign issues on macOS
externals: {
'node-hid': 'commonjs node-hid',
usb: 'commonjs usb'
}
})
const main = (env, arg) => {
console.log('Run `main` build ...')
return Object.assign({}, common(env, arg), {
entry: {
electron: './src/main/electron.ts'
},
target: 'electron-main',
externals: [nodeExternals()]
})
}
const preload = (env, arg) => {
console.log('Run `preload` build ...')
return Object.assign({}, common(env, arg), {
entry: {
preload: './src/main/preload.ts'
},
target: 'electron-preload'
})
}
module.exports = [main, preload]