-
-
Notifications
You must be signed in to change notification settings - Fork 29
/
webpack.main.config.js
62 lines (59 loc) · 1.52 KB
/
webpack.main.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
/*
* Copyright: (c) 2024, Alex Kaul
* GNU General Public License v3.0 or later (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
*/
const path = require('path');
const webpack = require('webpack');
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
const configFile = path.join(__dirname, 'src', 'main', 'tsconfig.json');
const configFileObj = require(configFile);
const isProd = process.env.NODE_ENV === 'production';
const isDev = !isProd;
module.exports = {
mode: isProd ? 'production' : 'development',
devtool: isProd ? undefined : 'source-map',
entry: {
main: path.join(__dirname, 'src', 'main', 'index.ts'),
},
output: {
path: path.join(__dirname, 'build'),
filename: '[name].js'
},
resolve: {
extensions: ['.ts', '.js'],
plugins: [new TsconfigPathsPlugin({
configFile
})]
},
target: 'electron-main',
module: {
rules: [
{
test: /\.ts$/,
use: [
{
loader: 'swc-loader',
options: {
jsc: {
target: configFileObj.target,
paths: configFileObj.paths,
},
},
},
],
exclude: /node_modules/,
}
]
},
plugins: [
new webpack.EnvironmentPlugin({
NODE_ENV: 'development',
}),
isDev && new ForkTsCheckerWebpackPlugin({ typescript: { configFile } }),
],
node: {
__dirname: false,
__filename: false,
}
}