-
-
Notifications
You must be signed in to change notification settings - Fork 29
/
webpack.renderer.additions.js
60 lines (53 loc) · 1.64 KB
/
webpack.renderer.additions.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 webpack = require("webpack");
const pkg = require("./package.json");
const moment = require("moment");
const Dotenv = require("dotenv-webpack");
const commitHash = require("child_process").execSync("git rev-parse --short HEAD").toString();
module.exports = function (context) {
// Add web worker support. This needs to be processed before the other rules so use unshift.
context.module.rules.unshift({
test: /\.worker\.(js|ts)$/i,
use: [
{
loader: "comlink-loader",
options: {
singleton: true,
},
},
],
});
context.module.rules.push(
// Fix iconv-lite issue, webpack require issue
// https://github.com/ashtuchkin/iconv-lite/issues/204#issuecomment-432048618
{
test: /node_modules[\/\\](iconv-lite)[\/\\].+/,
resolve: {
aliasFields: ["main"],
},
}
);
// Fix web workers not working with HMR
context.output.globalObject = "this";
// Expose dotenv variables
context.plugins.push(new Dotenv());
// Add globals
context.plugins.push(
new webpack.DefinePlugin({
__VERSION__: JSON.stringify(pkg.version),
__DATE__: JSON.stringify(moment().format("LLL")),
__BUILD__: JSON.stringify(commitHash),
})
);
// Fix issues with importing unsupported fsevents module in Windows and Linux
// For more info, see: https://github.com/vinceau/project-clippi/issues/48
if (process.platform !== "darwin") {
context.plugins.push(
new webpack.IgnorePlugin({
resourceRegExp: /^fsevents$/,
})
);
}
// Fix dependencies
context.externals = [...Object.keys(pkg.dependencies || {})];
return context;
};