-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.main.config.js
60 lines (59 loc) · 1.72 KB
/
webpack.main.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
const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const isWebpackDevServer = process.argv[1].indexOf('webpack-dev-server') !== -1
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const webpack = require('webpack')
const src = path.join(__dirname, 'src')
const port = process.env.PORT || 8081
const mode = isWebpackDevServer ? "development" : "production"
const nodeExternals = require('webpack-node-externals');
module.exports = {
mode,
target: 'electron-main',
entry: {
app: [path.join(__dirname, "./src/main/index.ts")]
},
output: {
path: path.join(__dirname, 'dist'),
filename: 'main.js'
},
optimization: {
// We no not want to minimize our code.
minimize: false
},
module: {
rules: [
{
test: /\.ts$/,
loader: "ts-loader",
options: {
configFile: 'tsconfig.server.json',
// forceIsolatedModules: true,
// useTranspileModule: true
},
include: src,
exclude: [
/node_modules/,
path.join(__dirname, "src/renderer")
]
}
]
},
resolve: {
// Add '.ts' and '.tsx' as resolvable extensions.
modules: ["node_modules"],
extensions: [".ts", ".tsx", ".js", ".json"]
},
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
})
],
node: {
__dirname: false,
__filename: false
},
externals: [nodeExternals({
whitelist: ['typeorm']
})]
}