forked from pitr/gemini-ios
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
64 lines (58 loc) · 1.88 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 glob = require("glob");
const path = require("path");
const UglifyJsPlugin = require("terser-webpack-plugin");
const AllFramesAtDocumentStart = glob.sync("./Client/Frontend/UserContent/UserScripts/AllFrames/AtDocumentStart/*.js");
const AllFramesAtDocumentEnd = glob.sync("./Client/Frontend/UserContent/UserScripts/AllFrames/AtDocumentEnd/*.js");
const MainFrameAtDocumentStart = glob.sync("./Client/Frontend/UserContent/UserScripts/MainFrame/AtDocumentStart/*.js");
const MainFrameAtDocumentEnd = glob.sync("./Client/Frontend/UserContent/UserScripts/MainFrame/AtDocumentEnd/*.js");
// Ensure the first script loaded at document start is __gemini__.js
// since it defines the `window.__gemini__` global.
const needsFirefoxFile = {
AllFramesAtDocumentStart,
// PDF content does not execute user scripts designated to
// run at document start for some reason. So, we also need
// to include __gemini__.js for the document end scripts.
// ¯\_(ツ)_/¯
AllFramesAtDocumentEnd,
};
for (let [name, files] of Object.entries(needsFirefoxFile)) {
if (path.basename(files[0]) !== "__gemini__.js") {
throw `ERROR: __gemini__.js is expected to be the first script in ${name}.js`;
}
}
module.exports = {
mode: "production",
entry: {
AllFramesAtDocumentStart,
AllFramesAtDocumentEnd,
MainFrameAtDocumentStart,
MainFrameAtDocumentEnd,
},
output: {
filename: "[name].js",
path: path.resolve(__dirname, "Client/Assets")
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules\/(?!(readability|page-metadata-parser)\/).*/,
use: {
loader: "babel-loader",
options: {
presets: [
["@babel/preset-env", {
targets: {
iOS: "10.3"
}
}]
]
}
}
}
]
},
plugins: [
new UglifyJsPlugin()
]
};