This repository has been archived by the owner on Jun 23, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 26
/
webpack.config.js
59 lines (55 loc) · 2.07 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
const glob = require("glob");
const path = require("path");
const UglifyJsPlugin = require("uglifyjs-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 __firefox__.js
// since it defines the `window.__firefox__` global.
if (path.basename(AllFramesAtDocumentStart[0]) !== "__firefox__.js") {
throw "ERROR: __firefox__.js is expected to be the first script in AllFramesAtDocumentStart.js";
}
// Ensure the first script loaded at document end is __firefox__.js
// since it also defines the `window.__firefox__` global because PDF
// content does not execute user scripts designated to run at document
// start for some reason. ¯\_(ツ)_/¯
if (path.basename(AllFramesAtDocumentEnd[0]) !== "__firefox__.js") {
throw "ERROR: __firefox__.js is expected to be the first script in AllFramesAtDocumentEnd.js";
}
module.exports = {
mode: "production",
entry: {
AllFramesAtDocumentStart: AllFramesAtDocumentStart,
AllFramesAtDocumentEnd: AllFramesAtDocumentEnd,
MainFrameAtDocumentStart: MainFrameAtDocumentStart,
MainFrameAtDocumentEnd: 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: [
["env", {
targets: {
iOS: "10.3"
}
}]
]
}
}
}
]
},
plugins: [
new UglifyJsPlugin()
]
};