-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
90 lines (85 loc) · 2.84 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
const webpack = require("webpack")
const path = require("path")
const scriptVersion = require("./package.json").version.replace(/(\.0)+$/, "")
const preactVersion = require("preact/package.json").version
const jqueryVersion = require("jquery/package.json").version
module.exports = {
mode: "none",
entry: {
autoupdate: "./src/entry.noupdatecheck.ts",
autocheck: "./src/entry.updatecheck.ts",
folio: "./src/entry.noupdatecheck.ts",
},
module: {
rules: [
{
test: /\.tsx?$/,
use: "ts-loader",
include: path.resolve(__dirname, "src"),
},
],
},
resolve: {
extensions: [".js", ".ts", ".tsx"],
modules: ["./node_modules", "./src"],
alias: {
jquery: "jquery/dist/jquery.slim.min.js",
},
},
plugins: [
new webpack.ProgressPlugin((percentage, message, ...args) => {
console.info(`${(100 * percentage).toFixed(0)}%`, message, ...args)
}),
new webpack.DefinePlugin({
VERSION: JSON.stringify(scriptVersion),
PREACT_VERSION: JSON.stringify(preactVersion),
JQUERY_VERSION: JSON.stringify(jqueryVersion),
}),
new webpack.BannerPlugin({
banner({chunk}) {
let update = ""
let scriptType
if (chunk.name === "autoupdate") {
scriptType = "automatic update"
update = `\
// @updateURL https://purkka.codes/oodi/oodiplusplus.autoupdate.user.js
// @downloadURL https://purkka.codes/oodi/oodiplusplus.autoupdate.user.js
`
} else if (chunk.name === "autocheck") {
scriptType = "automatic update check"
update = `\
// @grant GM_xmlhttpRequest
// @connect purkka.codes
`
} else {
scriptType = "tinfoil hat mode"
}
return `\
// ==UserScript==
// @name Oodi++ (${scriptType})
// @namespace https://purkka.codes/
// @version ${scriptVersion}
// @description Efficiently plan your timetable right in Oodi and export it to your calendar.
// @author PurkkaKoodari
// @include https://oodi.aalto.fi/*
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_addStyle
${update}// ==/UserScript==
/*! Oodi++ is licensed under the MIT license. */
/*! Includes jQuery v${jqueryVersion} | (c) JS Foundation and other contributors | jquery.org/license */
/*! Includes Preact v${preactVersion} | https://preactjs.com/ | MIT License */
`
},
raw: true,
entryOnly: true,
}),
],
output: {
filename: "./oodiplusplus.[name].user.js",
path: path.resolve(__dirname),
},
stats: {
maxModules: 100,
},
}