forked from streamwall/streamwall
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
123 lines (118 loc) · 2.42 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
const path = require('path')
const CopyPlugin = require('copy-webpack-plugin')
const baseConfig = ({ babel }) => ({
mode: 'development',
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: babel,
},
},
{
test: /\.css$/i,
use: ['style-loader', 'css-loader'],
},
{
test: /\.ttf$/,
loader: 'file-loader',
options: {
name: '[name].[ext]',
},
},
{
test: /\.svg$/,
loader: '@svgr/webpack',
options: {
replaceAttrValues: {
'#333': 'currentColor',
'#555': '{props.color}',
},
},
},
],
},
resolve: {
extensions: ['.jsx', '.js'],
alias: {
react: 'preact/compat',
'react-dom': 'preact/compat',
},
},
})
const nodeConfig = {
...baseConfig({
babel: {
presets: [
[
'@babel/preset-env',
{
modules: 'commonjs',
targets: { node: true },
},
],
],
},
}),
target: 'electron-main',
entry: {
index: './src/node/index.js',
},
externals: {
consolidate: 'commonjs consolidate',
fsevents: 'commonjs fsevents',
},
}
const browserConfig = {
...baseConfig({
babel: {
presets: [['@babel/preset-env', { targets: { electron: '11' } }]],
},
}),
devtool: 'cheap-source-map',
target: 'electron-renderer',
entry: {
background: './src/browser/background.js',
overlay: './src/browser/overlay.js',
layerPreload: './src/browser/layerPreload.js',
mediaPreload: './src/browser/mediaPreload.js',
playHLS: './src/browser/playHLS.js',
},
plugins: [
new CopyPlugin({
patterns: [{ from: 'src/browser/*.html', to: '[name].html' }],
}),
],
}
const webConfig = {
...baseConfig({
babel: {
presets: [
[
'@babel/preset-env',
{
modules: 'commonjs',
targets: '> 0.25%, not dead',
},
],
],
},
}),
devtool: 'cheap-source-map',
target: 'web',
entry: {
control: './src/web/control.js',
},
output: {
path: path.resolve(__dirname, 'dist/web'),
},
plugins: [
new CopyPlugin({
patterns: [{ from: 'src/web/*.ejs', to: '[name].ejs' }],
}),
],
}
module.exports = [nodeConfig, browserConfig, webConfig]