-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
webpack.config.renderer.js
70 lines (68 loc) · 1.63 KB
/
webpack.config.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
const path = require('path');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');
const mode = process.env.NODE_ENV || "development";
const staticPath =
mode === "production" ?
"`${path.join(process.resourcesPath, 'static')}`" :
"'static'";
module.exports = {
mode,
target: 'electron-renderer',
devtool: 'cheap-module-source-map',
entry: './src/renderer/index.tsx',
output: {
globalObject: 'this',
filename: 'renderer-index.js',
path: path.resolve(__dirname, 'build'),
publicPath: ''
},
optimization: {
minimize: false,
},
module: {
rules: [
{
test: /node_modules[/\\](iconv-lite)[/\\].+/,
resolve: {
aliasFields: ['main']
}
},
{
test: /\.(js|ts|tsx)$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader'
}
},
{
test: /\.(sa|sc|c)ss$/,
use: [
MiniCssExtractPlugin.loader,
{ loader: "css-loader", options: { sourceMap: true } },
],
},
{
test: /\.(png|jpe?g|gif|svg|eot|ttf|woff|woff2)$/,
use: ['file-loader'],
}
]
},
plugins: [
new webpack.ContextReplacementPlugin(/knex|express/),
new webpack.DefinePlugin({ '__static': staticPath }),
new MiniCssExtractPlugin({
filename: 'css/index.css'
}),
new HtmlWebpackPlugin({
template: 'public/index.html',
})
],
resolve: {
extensions: ['.ts', '.tsx', '.js']
},
externals: {
knex: 'commonjs knex',
}
};