-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.main.prod.js
89 lines (86 loc) · 2.24 KB
/
webpack.main.prod.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
const path = require('path');
const webpack = require('webpack');
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
module.exports = () => ({
mode: 'production',
devtool: 'source-map',
target: 'electron-main',
entry: path.join(__dirname, 'app/main/index.js'),
output: {
path: path.resolve(__dirname, 'lib'),
filename: 'main.prod.js',
},
resolve: {
extensions: ['.js', '.jsx', '.mjs', '.wasm', '.json'],
},
plugins: [
new webpack.EnvironmentPlugin({
DEBUG_PROD: false,
}),
new BundleAnalyzerPlugin({
analyzerMode: 'static',
}),
],
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
babelrc: false,
cacheDirectory: false,
presets: [
[
'@babel/preset-env',
{
targets: {
electron: '3.0.2',
},
modules: false,
useBuiltIns: 'entry',
},
],
],
plugins: [
'@babel/plugin-proposal-export-namespace-from',
'@babel/plugin-proposal-export-default-from',
'@babel/plugin-proposal-class-properties',
[
// used only for babel helpers
'@babel/plugin-transform-runtime',
{
// regenerator runtime should be used from global polyfill
regenerator: false,
// define babel helpers as es modules
useESModules: true,
},
],
],
},
},
},
{
test: /\.(?:ico|gif|png|jpg|jpeg|eot|webp)$/,
use: [
{
loader: 'file-loader',
options: {
name: 'images/[name].[ext]',
},
},
],
},
],
},
/**
* Disables webpack processing of __dirname and __filename.
* If you run the bundle in node.js it falls back to these values of node.js.
* https://github.com/webpack/webpack/issues/2010
*/
node: {
__dirname: false,
__filename: false,
},
});