-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
98 lines (92 loc) · 2.61 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
require('dotenv').config()
const path = require("path");
const UserscriptWebpackPlugin = require("./bin/UserscriptWebpackPlugin");
const TerserPlugin = require("terser-webpack-plugin");
const metadata = require("./bin/userscript-header");
const isDev = process.env.NODE_ENV == "development";
const files = [];
files.push({
entry: "./src/REMT.ts",
mode: isDev ? "development" : "production",
devtool: false,
plugins: [
new UserscriptWebpackPlugin({ metadata }),
],
module: {
rules: [
{
test: /\.tsx?$/,
use: "ts-loader",
exclude: /node_modules/,
},
{
test: /.scss$/,
exclude: /node_modules/,
use: [
"sass-to-string",
{
loader: "sass-loader",
options: {
sassOptions: { outputStyle: "compressed", },
},
},
],
},
],
},
resolve: {
extensions: [".tsx", ".ts", ".js"],
},
output: {
filename: "script.user.js",
path: path.resolve(__dirname, "dist"),
},
optimization: {
minimize: !isDev,
minimizer: [
(compiler) => {
new TerserPlugin({
terserOptions: {
format: { comments: false },
keep_classnames: true,
},
extractComments: false,
}).apply(compiler);
}
]
},
externals: [
"../../ZestyAPI/dist/ZestyAPI",
],
cache: true,
});
if (isDev) {
metadata.name = "RE621 ModTools Injector";
metadata.version = "10.0.0";
delete metadata.updateURL;
delete metadata.downloadURL;
if (process.env.INJ_TARGET == "firefox") metadata.require.push("http://localhost:7000/script.user.js");
else metadata.require.push("file://" + path.resolve(__dirname, "dist/script.user.js"));
files.push({
entry: "./bin/empty.js",
mode: "production",
plugins: [
new UserscriptWebpackPlugin({ metadata }),
],
output: {
filename: "injector.meta.js",
path: path.resolve(__dirname, "dist"),
},
});
} else files.push({
entry: "./bin/empty.js",
mode: "production",
plugins: [
new UserscriptWebpackPlugin({ metadata }),
],
output: {
filename: "script.meta.js",
path: path.resolve(__dirname, "dist"),
},
});
module.exports = files;