-
Notifications
You must be signed in to change notification settings - Fork 140
/
webpack.config.js
64 lines (60 loc) · 2.04 KB
/
webpack.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
const fs = require("fs");
const path = require("path");
const webpack = require("webpack");
const pkg = require("./package.json");
const pluginConfig = require("./src/config");
const buildMeta = require("./lib/meta");
const installScript = require("./lib/installscript");
const buildConfig = pkg.zplConfig;
pluginConfig.version = pkg.version;
const banner = buildMeta(pluginConfig) + "\n" + installScript;
module.exports = {
mode: "development",
target: "node",
devtool: false,
entry: "./src/index.js",
output: {
filename: "0PluginLibrary.plugin.js",
path: path.resolve(__dirname, "release"),
library: "ZeresPluginLibrary",
libraryTarget: "commonjs2",
libraryExport: "default",
compareBeforeEmit: false
},
externals: {
electron: `window.require("electron")`,
fs: `window.require("fs")`,
path: `window.require("path")`,
request: `window.require("request")`
},
resolve: {
extensions: [".js"],
modules: [
path.resolve("src", "modules"),
path.resolve("src", "structs"),
path.resolve("src", "ui")
]
},
module: {
rules: [{test: /\.css$/, use: "raw-loader"}]
},
optimization: {
minimize: false,
},
plugins: [
new webpack.DefinePlugin({"process.env": {__LIBRARY_VERSION__: JSON.stringify(pkg.version)}}),
new webpack.BannerPlugin({raw: true, banner: banner}),
new webpack.BannerPlugin({raw: true, banner: `/*@end@*/`, footer: true}),
{
apply: (compiler) => {
compiler.hooks.assetEmitted.tap("CopyToBD", (filename, info) => {
/* eslint-disable no-console */
if (!buildConfig.copyToBD) return;
const bdFolder = (process.platform == "win32" ? process.env.APPDATA : process.platform == "darwin" ? process.env.HOME + "/Library/Preferences" : process.env.XDG_CONFIG_HOME ? process.env.XDG_CONFIG_HOME : process.env.HOME + "/.config") + "/BetterDiscord/";
fs.copyFileSync(info.targetPath, path.join(bdFolder, "plugins", filename));
console.log(`\n\n✅ Copied to BD folder\n`);
});
}
},
]
};