This repository has been archived by the owner on Jul 2, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
webpack.config.js
109 lines (107 loc) · 2.75 KB
/
webpack.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
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
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin')
const TerserPlugin = require('terser-webpack-plugin')
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
/** @type import('webpack').Configuration */
module.exports = {
target: 'electron-renderer',
entry: {
tour: ['react-hot-loader/patch', './tour/index.jsx'],
main: [
'react-hot-loader/patch',
'./app/renderers/startup.js',
'./app/renderers/dialog.js',
'./app/renderers/menu.js',
'./app/index.jsx',
],
preview: ['react-hot-loader/patch', './preview/index.jsx'],
modal: ['react-hot-loader/patch', './modal/index.jsx'],
},
devtool: 'source-map',
output: {
path: path.resolve(__dirname, 'entrypoint'),
filename: '[name].prod.js',
},
resolve: {
extensions: ['.js', '.jsx'],
alias: {
'@styles': path.resolve(__dirname, 'static', 'css'),
'@images': [
path.resolve(__dirname, 'static', 'imgs'),
path.resolve(__dirname, 'tour', 'imgs')
],
'@components': [
path.resolve(__dirname, "app", "components"),
path.resolve(__dirname, "preview", "components"),
path.resolve(__dirname, "tour", "components"),
]
}
},
mode: 'production',
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader'
}
},
{
test: /\.html$/,
use: [
{
loader: 'html-loader'
}
]
},
{
test: /\.png|\.svg$/,
type: 'asset/resource'
},
{
test: /\.(css|sass|sacss|scss)$/,
use: [
MiniCssExtractPlugin.loader,
'css-loader',
'sass-loader'
]
}
]
},
plugins: [
new HtmlWebpackPlugin({
template: path.resolve(__dirname, 'app', 'app.html'),
filename: './main.html',
chunks: ['main']
}),
new HtmlWebpackPlugin({
template: path.resolve(__dirname, 'tour', 'tour.html'),
filename: './tour.html',
chunks: ['tour']
}),
new HtmlWebpackPlugin({
template: path.resolve(__dirname, 'preview', 'preview.html'),
filename: './preview.html',
chunks: ['preview']
}),
new HtmlWebpackPlugin({
template: path.resolve(__dirname, 'modal', 'modal.html'),
filename: './modal.html',
chunks: ['modal']
}),
new MiniCssExtractPlugin({
filename: '[name].css'
}),
new CleanWebpackPlugin(),
],
optimization: {
minimize: true,
minimizer: [
new CssMinimizerPlugin(),
new TerserPlugin(),
]
}
}