-
Notifications
You must be signed in to change notification settings - Fork 54
/
Copy pathwebpack.config.ts
54 lines (52 loc) · 1.36 KB
/
webpack.config.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
import { Configuration } from 'webpack'
export default (env: any, argv: Configuration) => {
const MAIN = !!(env && env.main)
const PRELOAD = !!(env && env.preload)
const PROD = !!(argv.mode && argv.mode === 'production')
if (PROD) {
process.env.NODE_ENV = 'production'
}
return {
target: MAIN || PRELOAD ? 'electron-main' : 'electron-renderer',
entry: MAIN
? './src/main/AppMain.ts'
: PRELOAD
? './src/common/Preload.ts'
: './src/renderer/AppRenderer.tsx',
output: {
path: PROD ? `${__dirname}/dist/src/assets` : `${__dirname}/src/assets`,
filename: MAIN ? 'main.js' : PRELOAD ? 'preload.js' : 'renderer.js'
},
devtool: PROD ? undefined : 'inline-source-map',
node: {
__dirname: false,
__filename: false
},
resolve: {
extensions: ['*', '.js', '.jsx', '.ts', '.tsx']
},
module: {
rules: [
{
test: /\.(ts|js)x?$/,
exclude: /node_modules/,
use: [
{
loader: 'ts-loader',
options: {
transpileOnly: true
}
},
{
loader: 'ifdef-loader',
options: {
env: PROD ? 'PRODUCTION' : 'DEBUG'
}
}
]
}
]
},
externals: MAIN || PRELOAD ? [] : ['electron']
}
}