-
Notifications
You must be signed in to change notification settings - Fork 479
/
webpack.main.config.js
90 lines (86 loc) · 2.05 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
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
/* eslint-disable @typescript-eslint/no-var-requires */
const plugins = require("./webpack.plugins");
const rules = require("./webpack.rules");
const CopyPlugin = require("copy-webpack-plugin");
const Path = require("path");
// Add support for native node modules
const mainRules = [
...rules,
{
test: /\.node$/,
use: "node-loader",
},
{
test: /\.(m?js|node)$/,
parser: { amd: false },
use: {
loader: "@vercel/webpack-asset-relocator-loader",
options: {
outputAssetBase: "native_modules",
},
},
},
];
const mainPlugins = [
...plugins,
new CopyPlugin({
patterns: [
{ from: "node_modules/about-window", to: "node_modules/about-window" },
{
from: "node_modules/vm2",
to: "node_modules/vm2",
info: { minimized: true },
},
{
from: "node_modules/acorn",
to: "node_modules/acorn",
},
{
from: "node_modules/acorn-walk",
to: "node_modules/acorn-walk",
},
],
}),
];
const srcPath = (subdir) => {
return Path.join(__dirname, "src", subdir);
};
module.exports = {
target: "electron-main",
/**
* This is the main entry point for your application, it's the first file
* that runs in the main process.
*/
entry: {
index: "./src/main.ts",
buildWorker: "./src/lib/compiler/buildWorker.ts",
},
output: {
path: __dirname + "/.webpack/main",
filename: "[name].js",
},
// Put your normal webpack config below here
module: {
rules: mainRules,
},
plugins: mainPlugins,
resolve: {
extensions: [".js", ".ts", ".jsx", ".tsx", ".wasm", ".css"],
alias: {
store: srcPath("store"),
components: srcPath("components"),
lang: srcPath("lang"),
lib: srcPath("lib"),
ui: srcPath("components/ui"),
shared: srcPath("shared"),
consts: srcPath("consts.ts"),
"patrons.json": Path.join(__dirname, "patrons.json"),
},
},
externals: {
vm2: "vm2",
"about-window": "about-window",
acorn: "acorn",
"acorn-walk": "acorn-walk",
},
};