-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathwebpack.renderer.config.js
More file actions
73 lines (66 loc) · 2.33 KB
/
webpack.renderer.config.js
File metadata and controls
73 lines (66 loc) · 2.33 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
// webpack.renderer.config.js
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const WebpackObfuscator = require('webpack-obfuscator');
const isProduction = process.env.NODE_ENV === 'production';
module.exports = {
mode: isProduction ? 'production' : 'development',
target: 'electron-renderer',
devtool: isProduction ? false : 'source-map',
entry: {
index: './src/renderer/js/index-main.js',
settings: './src/renderer/js/settings-main.js',
about: './src/renderer/js/about-main.js',
},
output: {
path: path.resolve(__dirname, 'dist/out/renderer'),
filename: 'js/[name].bundle.js',
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env'],
},
},
},
{
// This rule handles the compiled Tailwind CSS and Font Awesome CSS
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, 'css-loader'],
},
],
},
plugins: [
// --- Create a new HtmlWebpackPlugin for EACH of the pages ---
new HtmlWebpackPlugin({
template: './src/renderer/index.html', // Path to the source HTML
filename: 'index.html', // Name of the output HTML in 'dist/out/renderer/'
chunks: ['index'], // IMPORTANT: Inject only the 'index' JavaScript bundle
}),
new HtmlWebpackPlugin({
template: './src/renderer/settings.html',
filename: 'settings.html',
chunks: ['settings'],
}),
new HtmlWebpackPlugin({
template: './src/renderer/about.html',
filename: 'about.html',
chunks: ['about'],
}),
new MiniCssExtractPlugin({
filename: 'css/[name].styles.css',
}),
isProduction && new WebpackObfuscator({
compact: true,
selfDefending: true,
stringArray: true,
rotateStringArray: true,
}, []),
].filter(Boolean),
};