forked from brave/brave-ios
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
57 lines (51 loc) · 2.92 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
const glob = require("glob");
const path = require("path");
const TerserPlugin = require('terser-webpack-plugin');
const AllFramesAtDocumentStart = glob.sync("./Client/Frontend/UserContent/UserScripts/AllFrames/AtDocumentStart/*.js");
const AllFramesAtDocumentStartSandboxed = glob.sync("./Client/Frontend/UserContent/UserScripts/Sandboxed/AllFrames/AtDocumentStart/*.js");
const AllFramesAtDocumentEnd = glob.sync("./Client/Frontend/UserContent/UserScripts/AllFrames/AtDocumentEnd/*.js");
const AllFramesAtDocumentEndSandboxed = glob.sync("./Client/Frontend/UserContent/UserScripts/Sandboxed/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");
const MainFrameAtDocumentStartSandboxed = glob.sync("./Client/Frontend/UserContent/UserScripts/Sandboxed/MainFrame/AtDocumentStart/*.js");
const MainFrameAtDocumentEndSandboxed = glob.sync("./Client/Frontend/UserContent/UserScripts/Sandboxed/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";
}
if (path.basename(AllFramesAtDocumentStartSandboxed[0]) !== "__firefox__.js") {
throw "ERROR: __firefox__.js is expected to be the first script in AllFramesAtDocumentStartSandboxed.js";
}
if (path.basename(AllFramesAtDocumentEndSandboxed[0]) !== "__firefox__.js") {
throw "ERROR: __firefox__.js is expected to be the first script in AllFramesAtDocumentEndSandboxed.js";
}
module.exports = {
mode: "production",
entry: {
AllFramesAtDocumentStart: AllFramesAtDocumentStart,
AllFramesAtDocumentStartSandboxed: AllFramesAtDocumentStartSandboxed,
AllFramesAtDocumentEnd: AllFramesAtDocumentEnd,
AllFramesAtDocumentEndSandboxed: AllFramesAtDocumentEndSandboxed,
MainFrameAtDocumentStart: MainFrameAtDocumentStart,
MainFrameAtDocumentEnd: MainFrameAtDocumentEnd,
MainFrameAtDocumentStartSandboxed: MainFrameAtDocumentStartSandboxed,
MainFrameAtDocumentEndSandboxed: MainFrameAtDocumentEndSandboxed
},
// optimization: { minimize: false }, // use for debugging
output: {
filename: "[name].js",
path: path.resolve(__dirname, "Client/Assets")
},
module: {
rules: []
},
plugins: []
};