forked from philhk/better-discord-screenshare-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
61 lines (56 loc) · 1.52 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 banner from 'vite-plugin-banner';
import { resolve, join } from 'path';
import { betterDiscordConfig } from './betterdiscord.config';
import license from 'rollup-plugin-license';
// const OUT_DIR = resolve(`${process.env.APPDATA}/BetterDiscord/plugins`); // Use if you want to output in plugins folder directly.
const OUT_DIR = 'dist';
const FILE_NAME = `${betterDiscordConfig.name}.plugin.js`;
export default defineConfig(() => ({
plugins: [
banner({
content: `/**\n${Object.entries(betterDiscordConfig)
.map(([key, value]) => `* @${key} ${value}`)
.join('\n')}\n */`,
outDir: OUT_DIR,
}),
license({
sourcemap: true,
cwd: process.cwd(),
banner: {
commentStyle: 'ignored',
content: {
file: join(__dirname, 'LICENSE'),
},
},
thirdParty: {
includePrivate: true,
output: {
file: join(__dirname, 'dist', 'dependencies.txt'),
},
allow(dependency) {
return ['MIT', 'ISC'].includes(dependency.license);
},
},
}),
],
build: {
outDir: OUT_DIR,
minify: 'esbuild',
lib: {
entry: resolve(__dirname, 'src/index.tsx'),
name: betterDiscordConfig.name,
fileName: () => FILE_NAME,
formats: ['iife'],
},
rollupOptions: {
entry: resolve(__dirname, 'src/index.tsx'),
external: ['react'],
output: {
globals: {
react: 'BdApi.React',
},
},
},
},
}));