-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
61 lines (57 loc) · 1.68 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
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue2";
import { metablock } from "vite-plugin-userscript";
import { libInjectCss } from "vite-plugin-lib-inject-css";
import path from "path";
import { versions } from "./shared/config.js";
export default defineConfig((_commandLineArgs: object) => {
// Get the inputDir from the command line arguments
let inputDir = "";
process.argv.forEach((arg) => {
if (!arg.startsWith("--inputDir=")) return;
inputDir = arg.slice("--inputDir=".length);
});
// console.log(inputDir);
return {
build: {
cssMinify: false,
minify: false,
emptyOutDir: false,
lib: {
entry: path.join(inputDir, "main.ts"),
fileName: (_format, _entryName) => `awbw_${inputDir}.user.js`,
name: "awbw_" + inputDir,
formats: ["iife"],
},
rollupOptions: {
external: ["howler", "spark-md5", "can-autoplay", "vue"],
output: {
format: "iife",
globals: {
howler: "Howl",
"spark-md5": "SparkMD5",
"can-autoplay": "canAutoplay",
vue: "Vue",
},
},
},
},
plugins: [
libInjectCss(),
vue(),
metablock({
file: path.join(inputDir, "metadata.json5"),
manager: "tampermonkey",
validator: "error",
override: {
version: versions.get(inputDir),
supportURL: "https://github.com/DeveloperJose/JS-AWBW-User-Scripts/issues",
namespace: "https://awbw.amarriner.com/",
contributionURL: "https://ko-fi.com/developerjose",
license: "MIT",
unwrap: true,
},
}),
],
};
});