-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathwebpack.config.js
More file actions
75 lines (69 loc) · 1.57 KB
/
webpack.config.js
File metadata and controls
75 lines (69 loc) · 1.57 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
const path = require('path')
const htmlWebPackPlugin = require('html-webpack-plugin') // compiles html react entry point
const nodeExternals = require('webpack-node-externals') // excludes packing external modules.
const MiniCssExtractPlugin = require('mini-css-extract-plugin') //
const jsRule = {
test: /\.(js|jsx)?$/,
use: {
loader: 'babel-loader'
}
}
const electronMainConfig = {
target: 'electron-main',
externals: [nodeExternals()],
entry: './main.js',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'main.bundle.js'
},
module: {
rules: [ jsRule ]
},
devtool: 'source-map',
plugins: [ ]
}
const htmlRule = {
test: /\.html$/,
use: [
{
loader: 'html-loader',
options: { minimize: true }
}
]
}
const cssRule = { // TODO: fix css bundling
test: /\.css$/,
use: [
{
loader: MiniCssExtractPlugin.loader,
options: { publicPath: './css' }
},
'css-loader'
]
}
const electronRendererConfig = {
target: 'electron-renderer',
externals: [nodeExternals()],
entry: './src-react/App.jsx',
output: {
path: path.resolve(__dirname, 'dist', 'src-react'),
filename: 'app.bundle.js'
},
module: {
rules: [ jsRule, htmlRule ]
},
resolve: {
extensions: [ '.js', '.jsx']
},
devtool: 'source-map',
plugins: [
new htmlWebPackPlugin({
template: './index.html',
filename: 'index.html'
}),
new MiniCssExtractPlugin({// TODO: fix css bundling
filename: 'style.bundle.css'
})
]
}
module.exports = [ electronMainConfig, electronRendererConfig ]