-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathvite.config.ts
81 lines (77 loc) · 2.19 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import { svelte } from '@sveltejs/vite-plugin-svelte';
import path from 'path';
import copy from 'rollup-plugin-copy';
import { defineConfig } from 'vite';
import webExtension, { readJsonFile } from 'vite-plugin-web-extension';
import zipPack from 'vite-plugin-zip-pack';
const pkg = readJsonFile('package.json');
const manifest = readJsonFile('src/manifest.json');
const browser = process.env.BROWSER ?? 'chrome';
const version = process.env.VERSION ?? pkg.version;
const buildDir = `build/${browser}`;
export default defineConfig({
root: 'src',
build: {
outDir: path.resolve(__dirname, buildDir),
emptyOutDir: true,
minify: process.env.MINIFY !== 'false' ? 'terser' : false,
},
define: {
__BROWSER__: JSON.stringify(browser),
__VERSION__: JSON.stringify(version)
},
plugins: [
webExtension({
manifest: () => {
const newManifest = {
...manifest,
version: (process.env.VERSION ?? '').split('-')[0] || manifest.version
};
if ('browser_specific_settings' in newManifest && process.env.ADDON_ID) {
newManifest.browser_specific_settings.gecko.id = process.env.ADDON_ID;
}
return newManifest;
},
assets: 'assets',
watchFilePaths: [
path.resolve(__dirname, 'src/manifest.json')
],
additionalInputs: [
'hyperchat.html',
'setup.html',
'scripts/chat-interceptor.ts',
'scripts/chat-metagetter.ts'
],
disableAutoLaunch: process.env.AUTOLAUNCH !== 'true',
browser,
webExtConfig: {
startUrl: 'https://www.youtube.com/watch?v=jfKfPfyJRdk'
},
libModeViteConfig: defineConfig({
build: {
rollupOptions: {
output: {
inlineDynamicImports: true,
},
},
},
}),
}),
svelte({
configFile: path.resolve(__dirname, 'svelte.config.js'),
emitCss: false
}),
copy({
hook: 'writeBundle',
targets: [{
src: 'src/stylesheets/*',
dest: `${buildDir}/stylesheets`
}]
}),
zipPack({
inDir: buildDir,
outDir: 'build',
outFileName: `YtcFilter-${browser}.zip`
})
]
});