forked from ytmdesktop/ytmdesktop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.main.config.ts
59 lines (53 loc) · 1.86 KB
/
webpack.main.config.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
import { DefinePlugin, type Configuration } from "webpack";
import path from "path";
import { rules } from "./webpack.rules";
// This needs an eslint disable for now to clear the warning
// eslint-disable-next-line @typescript-eslint/no-var-requires
const relocateLoader = require("@vercel/webpack-asset-relocator-loader");
rules.push({
test: /\.tsx?$/,
exclude: /(node_modules|\.webpack)/,
use: {
loader: "ts-loader",
options: {
transpileOnly: true,
configFile: path.join(__dirname, "src/main/tsconfig.json")
}
}
});
export const mainConfig: Configuration = {
/**
* This is the main entry point for your application, it's the first file
* that runs in the main process.
*/
entry: "./src/main/index.ts",
// Put your normal webpack config below here
module: {
rules
},
plugins: [
new DefinePlugin({
YTMD_DISABLE_UPDATES: false,
YTMD_UPDATE_FEED_OWNER: `'${process.env.YTMD_UPDATE_FEED_OWNER}'` ?? "'ytmdesktop'",
YTMD_UPDATE_FEED_REPOSITORY: `'${process.env.YTMD_UPDATE_FEED_REPOSITORY}'` ?? "'ytmdesktop'"
}),
{
// This fixes issues with webpack where natives or other were not being properly configured and relocated because of an undefined variable in webpack
// Waiving this explicit any for now
// eslint-disable-next-line @typescript-eslint/no-explicit-any
apply(compiler: any) {
compiler.hooks.compilation.tap("webpack-asset-relocator-loader", (compilation: unknown) => {
relocateLoader.initAssetCache(compilation, "native_modules");
});
}
}
],
resolve: {
alias: {
"~shared": path.resolve(__dirname, "src/shared"),
"~assets": path.resolve(__dirname, "src/assets")
},
extensions: [".js", ".ts", ".jsx", ".tsx", ".css", ".json"]
},
devtool: process.env.NODE_ENV === "development" ? "eval-source-map" : false
};