forked from lensapp/lens
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.main.ts
executable file
·62 lines (56 loc) · 1.61 KB
/
webpack.main.ts
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
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import path from "path";
import type webpack from "webpack";
import ForkTsCheckerPlugin from "fork-ts-checker-webpack-plugin";
import nodeExternals from "webpack-node-externals";
import * as vars from "./src/common/vars";
import getTSLoader from "./src/common/getTSLoader";
import CircularDependencyPlugin from "circular-dependency-plugin";
import { iconsAndImagesWebpackRules } from "./webpack.renderer";
const configs: { (): webpack.Configuration }[] = [];
configs.push((): webpack.Configuration => {
console.info("WEBPACK:main", vars);
const { mainDir, buildDir, isDevelopment } = vars;
return {
context: __dirname,
target: "electron-main",
mode: isDevelopment ? "development" : "production",
devtool: isDevelopment ? "cheap-module-source-map" : "source-map",
cache: isDevelopment,
entry: {
main: path.resolve(mainDir, "index.ts"),
},
output: {
libraryTarget: "global",
path: buildDir,
},
resolve: {
extensions: [".json", ".js", ".ts"],
},
externals: [
nodeExternals(),
],
module: {
rules: [
{
test: /\.node$/,
use: "node-loader",
},
getTSLoader({}, /\.ts$/),
...iconsAndImagesWebpackRules(),
],
},
plugins: [
new ForkTsCheckerPlugin(),
new CircularDependencyPlugin({
cwd: __dirname,
exclude: /node_modules/,
failOnError: true,
}),
].filter(Boolean),
};
});
export default configs;