-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
vite.config.ts
84 lines (83 loc) · 2.41 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
82
83
84
import { defineConfig } from 'vite';
import { svelte } from '@sveltejs/vite-plugin-svelte';
import browserExtension from 'vite-plugin-web-extension';
import path from 'path';
import copy from 'rollup-plugin-copy';
import manifest from './src/manifest.json';
export default defineConfig({
root: 'src',
build: {
outDir: path.resolve(__dirname, 'build'),
emptyOutDir: true,
minify: process.env.MINIFY !== 'false' ? 'terser' : false,
},
plugins: [
browserExtension({
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.HC_AUTOLAUNCH === undefined,
browser: process.env.BROWSER === undefined ? 'chrome' : process.env.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: 'build/manifest.json',
dest: 'build/',
transform: (content) => {
const newManifest = JSON.parse(content.toString());
if ('incognito' in newManifest) {
delete newManifest.incognito;
}
if ('service_worker' in newManifest.background) {
newManifest.background = {
scripts: [newManifest.background.service_worker]
};
}
return JSON.stringify(newManifest, null, 2);
},
rename: 'manifest.firefox.json'
}]
}),
copy({
hook: 'writeBundle',
targets: [{
src: 'src/stylesheets/*',
dest: 'build/stylesheets'
}]
}),
]
});