forked from Scarwolf/p0weruser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
62 lines (60 loc) · 2.31 KB
/
vite.config.ts
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
import path from "path";
import { defineConfig } from "vite";
import monkey, { cdn } from "vite-plugin-monkey";
import * as pkg from "./package.json";
const getFileName = (mode: "production" | string) => mode === 'production' ? 'p0weruser.user.js' : 'p0weruser.dev.user.js';
const getScriptUrl = (mode: "production" | string) => `https://scarwolf.github.io/p0weruser/${getFileName(mode)}`;
export default defineConfig(({ mode }) => ({
plugins: [
monkey({
entry: "src/P0weruser.ts",
userscript: {
name: "p0weruser - Rel0aded" + (mode === "production" ? "" : " [Dev]"),
author: "PoTTii - Created by Florian Maak",
namespace: "https://github.com/Scarwolf/p0weruser/",
license: "GPL-3.0; http://www.gnu.org/licenses/gpl-3.0.txt",
include: "/^https?://pr0gramm.com/.*$/",
icon: "https://pr0gramm.com/media/pr0gramm-favicon.png",
connect: [
"rep0st.rene8888.at",
"github.com",
"raw.githubusercontent.com",
"pr0gramm.com",
],
"run-at": "document-end",
require: ["https://code.jquery.com/ui/1.13.1/jquery-ui.min.js"],
resource: {
customCSS:
"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css",
},
// The -dev suffix might not be enough to provide a continous dev version. It should work if the script is also
// newer to still receive an update but this is different between script engines. If so, we most likely need to
// append another suffix (Maybe Date or GitHub Run ID).
version:
pkg.version + (mode === "production" ? "" : `-dev-${Date.now()}`),
updateURL: getScriptUrl(mode),
downloadURL: getScriptUrl(mode),
},
build: {
fileName: getFileName(mode),
externalGlobals: {
// Keep attentention on the casing in this list
"chart.js": cdn.jsdelivr("Chart", "dist/Chart.min.js"),
"tesseract.js": cdn.jsdelivr("Tesseract", "dist/tesseract.min.js"),
},
externalResource: {
"font-awesome": cdn.jsdelivr("font-awesome", "css/all.min.css"),
},
},
}),
],
build: {
minify: true,
},
resolve: {
alias: {
"@": path.resolve(__dirname, "src"),
},
},
assetsInclude: ["assets/**"],
}));