-
-
Notifications
You must be signed in to change notification settings - Fork 380
Expand file tree
/
Copy pathwebpack.config.js
More file actions
85 lines (75 loc) · 1.99 KB
/
webpack.config.js
File metadata and controls
85 lines (75 loc) · 1.99 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
const path = require("node:path");
const webpack = require("webpack");
const pluginConfig = require("./src/config.json");
const process = require("node:process");
const fs = require("node:fs");
const meta = (() => {
const lines = ["/**"];
for (const key in pluginConfig) {
if (key === "changelog") continue;
lines.push(` * @${key} ${pluginConfig[key]}`);
}
lines.push(" */");
return lines.join("\n");
})();
module.exports = {
mode: "development",
target: "node",
devtool: false,
entry: "./src/index.js",
output: {
filename: "ShowHiddenChannels.plugin.js",
path: path.join(__dirname, "dist"),
libraryTarget: "commonjs2",
libraryExport: "default",
compareBeforeEmit: false,
},
resolve: {
extensions: [".js", ".css", ".jsx"],
},
module: {
rules: [
{ test: /\.css$/, use: "raw-loader" },
{ test: /\.jsx$/, exclude: /node_modules/, use: "babel-loader" },
],
},
plugins: [
new webpack.BannerPlugin({ raw: true, banner: meta }),
{
apply: (compiler) => {
compiler.hooks.assetEmitted.tap(
"ShowHiddenChannels",
(filename, info) => {
console.info(`\n\nℹ️ Plugin built as ${filename}\n`);
const userConfig = (() => {
if (process.platform === "win32") return process.env.APPDATA;
if (process.platform === "darwin") {
return path.join(
process.env.HOME,
"Library",
"Application Support",
);
}
if (process.env.XDG_CONFIG_HOME) {
return process.env.XDG_CONFIG_HOME;
}
return path.join(process.env.HOME, "Library", ".config");
})();
const bdFolder = path.join(userConfig, "BetterDiscord");
fs.copyFileSync(
info.targetPath,
path.join(bdFolder, "plugins", filename),
);
console.info("\n\n✅ Copied to BD folder\n");
},
);
},
},
new webpack.DefinePlugin({
__VERSION__: JSON.stringify(pluginConfig.version),
}),
new webpack.DefinePlugin({
__CHANGELOG__: JSON.stringify(pluginConfig.changelog),
}),
],
};