-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
110 lines (108 loc) · 2.36 KB
/
webpack.config.js
File metadata and controls
110 lines (108 loc) · 2.36 KB
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
const path = require("node:path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
module.exports = (_env, argv) => {
const common = {
mode: argv.mode,
resolve: {
extensions: [".ts", ".tsx", ".js", ".jsx"],
alias: {
"@": path.resolve(__dirname, "src"),
"@main": path.resolve(__dirname, "src/main"),
"@ui": path.resolve(__dirname, "src/renderer"),
"@preload": path.resolve(__dirname, "src/preload"),
},
},
module: {
rules: [
{
test: /\.[jt]sx?$/,
exclude: /node_modules/,
use: {
loader: "ts-loader",
options: { transpileOnly: true },
},
},
{
test: /\.module\.css$/,
use: [
MiniCssExtractPlugin.loader,
{
loader: "css-loader",
options: {
modules: true,
esModule: false,
},
},
],
},
{
test: /\.css$/,
exclude: /\.module\.css$/,
use: [
MiniCssExtractPlugin.loader,
{
loader: "css-loader",
options: { importLoaders: 1 },
},
],
},
{
test: /\.(png|jpe?g|gif|svg)$/,
type: "asset/resource",
},
],
},
devtool: argv.mode === "development" ? "source-map" : false,
};
return [
{
...common,
name: "main",
entry: {
main: "./src/main/main.ts",
preload: "./src/preload/preload.ts",
},
target: "electron-main",
output: {
path: path.resolve(__dirname, "dist"),
filename: "[name].js",
},
externals: [{ sharp: "commonjs sharp" }],
},
{
...common,
name: "renderer",
entry: {
index: "./src/renderer/apps/MainApp/index.tsx",
contextMenu: "./src/renderer/apps/MenuApp/index.tsx",
settings: "./src/renderer/apps/SettingsApp/index.tsx",
},
target: "electron-renderer",
output: {
path: path.resolve(__dirname, "dist"),
filename: "[name].js",
},
plugins: [
new HtmlWebpackPlugin({
template: "./public/index.html",
filename: "index.html",
chunks: ["index"],
}),
new HtmlWebpackPlugin({
template: "./public/menu.html",
filename: "menu.html",
chunks: ["contextMenu"],
}),
new HtmlWebpackPlugin({
template: "./public/settings.html",
filename: "settings.html",
chunks: ["settings"],
}),
new MiniCssExtractPlugin({
filename: "[name].css",
}),
],
},
];
};