forked from seokju-na/geeks-diary
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.electron.js
63 lines (55 loc) · 1.5 KB
/
webpack.electron.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
const { DefinePlugin, NoEmitOnErrorsPlugin } = require('webpack');
const path = require('path');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const PROD = process.env.NODE_ENV === 'production';
const config = {
name: 'main-process',
mode: PROD ? 'production' : 'development',
devtool: 'source-map',
entry: {
main: path.resolve(__dirname, 'src/main-process/main.ts'),
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].js',
},
resolve: {
extensions: ['.ts', '.js', '.json'],
},
module: {
rules: [
{
test: /\.ts$/,
loader: 'awesome-typescript-loader',
exclude: [/node_modules/, /dist/, /assets/, /test/],
options: {
configFileName: path.resolve(__dirname, 'tsconfig.electron.json'),
},
},
],
},
plugins: [
new NoEmitOnErrorsPlugin(),
new DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify(process.env.NODE_ENV),
},
}),
],
node: {
__dirname: false,
__filename: false,
},
target: 'electron-main',
externals: {
nodegit: 'require("nodegit")',
'@sentry/electron': 'require("@sentry/electron")',
},
};
if (PROD) {
config.plugins.push(new UglifyJsPlugin({
uglifyOptions: { ecma: 6 },
sourceMap: true,
}));
}
module.exports = config;