-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.electron.config.js
62 lines (59 loc) · 1.61 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
'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',
});
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({
VERSION: JSON.stringify(gitRevisionPlugin.version()),
COMMITHASH: JSON.stringify(gitRevisionPlugin.commithash()),
BRANCH: JSON.stringify(gitRevisionPlugin.branch()),
LASTCOMMITDATETIME: JSON.stringify(gitRevisionPlugin.lastcommitdatetime()),
})
],
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']
},
target: 'electron-preload'
}
];