-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvite.config.ts
More file actions
101 lines (95 loc) · 2.29 KB
/
vite.config.ts
File metadata and controls
101 lines (95 loc) · 2.29 KB
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
91
92
93
94
95
96
97
98
99
100
101
import path from "node:path";
import { cwd } from "node:process";
import { defineConfig } from "vite";
import cleanCss from "vite-plugin-clean-css";
function jsBanner(sourcePath: string) {
return `/** @license
* This file is auto-generated. Do not edit directly.
* @see https://github.com/vrchat-community/wiki-scripts/blob/main/${sourcePath}
*/
`;
}
function cssBanner(sourcePath: string) {
return `/*!
* This file is auto-generated. Do not edit directly.
* https://github.com/vrchat-community/wiki-scripts/blob/main/${sourcePath}
*/
`;
}
export default defineConfig({
resolve: {
tsconfigPaths: true
},
build: {
target: "es2015",
assetsDir: "",
modulePreload: false,
cssTarget: "chrome88",
minify: false,
rolldownOptions: {
input: {
"MediaWiki:Common": "./src",
"MediaWiki:Timeless": "./src/themes/timeless/index.scss"
},
output: {
format: "cjs",
inlineDynamicImports: true,
minify: {
compress: {
sequences: false,
joinVars: false,
},
codegen: {
removeWhitespace: false
},
mangle: {
keepNames: true
}
},
sanitizeFileName: false,
entryFileNames: "[name].js",
assetFileNames: "[name].[ext]",
// MediaWiki doesn't isolate scripts, every declared variable is global.
// https://developer.mozilla.org/en-US/docs/Glossary/IIFE
intro: "(()=>{",
outro: "})()",
banner: ({ facadeModuleId }) => jsBanner(path.relative(cwd(), facadeModuleId ?? ""))
}
}
},
plugins: [
cleanCss({
level: {
1: {
all: true
},
2: {
all: true,
removeUnusedAtRules: false
}
},
format: "beautify"
}),
{
name: "css-banner",
enforce: "post",
generateBundle(_, bundle) {
for (const [fileName, asset] of Object.entries(bundle)) {
if (asset.type !== "asset" || !fileName.endsWith(".css"))
continue;
const sourcePath = path.relative(cwd(), asset.originalFileNames[0] ?? "");
asset.source = cssBanner(sourcePath) + asset.source;
}
}
}
],
experimental: {
// Font files were uploaded separately.
renderBuiltUrl: (filename) => {
if (filename.startsWith("exo-2"))
return `https://wiki-files.vrchat.com/fonts/${filename}`;
if (filename.startsWith("noto-sans"))
return `https://wiki-files.vrchat.com/fonts/${filename}`;
}
}
});