forked from project-slippi/slippi-launcher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.renderer.additions.js
38 lines (30 loc) · 1.12 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
const TsconfigPathsPlugin = require("tsconfig-paths-webpack-plugin");
const pkg = require("./package.json");
const Dotenv = require("dotenv-webpack");
const { DefinePlugin } = require("webpack");
const moment = require("moment");
const buildDate = moment().toISOString();
const commitHash = require("child_process").execSync("git rev-parse --short HEAD").toString().trim();
module.exports = function (context) {
// Expose dotenv variables
context.plugins.push(new Dotenv());
// Ensure our custom paths can be resolved
context.resolve.plugins = [new TsconfigPathsPlugin()];
// Ensure all dependencies are marked as external.
// Without this, we randomly get "Invalid hook call" errors.
context.externals.push(...Object.keys(pkg.dependencies || {}));
// Allow importing raw SVGs
context.module.rules.push({
test: /\.svg$/,
use: ["@svgr/webpack", "url-loader"],
});
// Add global definitions
context.plugins.push(
new DefinePlugin({
__VERSION__: JSON.stringify(pkg.version),
__DATE__: JSON.stringify(buildDate),
__COMMIT__: JSON.stringify(commitHash),
}),
);
return context;
};