This repository has been archived by the owner on Sep 30, 2023. It is now read-only.
/
webpack.renderer.js
79 lines (77 loc) · 2.15 KB
/
webpack.renderer.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
const path = require('path');
const CopyPlugin = require('copy-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CspHtmlWebpackPlugin = require('csp-html-webpack-plugin');
const ESLintPlugin = require('eslint-webpack-plugin');
let devtool = 'source-map';
let sourceType = 'development';
if (process.env.NODE_ENV === 'production') {
devtool = undefined;
sourceType = 'production.min';
}
module.exports = {
mode: 'development',
devtool: devtool,
entry: './src/renderer/index.tsx',
resolve: {
extensions: ['.ts', '.tsx', '.js', '.html']
},
plugins: [
new HtmlWebpackPlugin({
template: 'html/index.' + sourceType + '.html'
}),
new CspHtmlWebpackPlugin({
'script-src': []
}),
new CopyPlugin({
patterns: [
{ from: 'img/*', to: 'assets' },
{ from: 'node_modules/react/umd/react.' + sourceType + '.js', to: 'assets/js/' },
{ from: 'node_modules/react-dom/umd/react-dom.' + sourceType + '.js', to: 'assets/js/' },
]
}),
new ESLintPlugin({
extensions: ['.ts', '.tsx']
}),
],
target: 'electron-renderer',
module: {
rules: [
{
test: /\.ts(x?)$/,
exclude: /node_modules/,
use: [
{
loader: 'ts-loader'
}
]
},
{
test: /\.(woff|woff2)$/,
type: 'asset/resource',
},
{
enforce: 'pre',
test: /\.js$/,
loader: 'source-map-loader'
},
{
test: /\.s[ac]ss$/i,
use: [
'style-loader',
'css-loader',
'sass-loader',
],
},
]
},
externals: {
'react': 'React',
'react-dom': 'ReactDOM',
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'app.js',
hashFunction: 'xxhash64',
},
};