-
-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathvite.config.ts
65 lines (61 loc) · 1.66 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
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: () => ({
...manifest,
version
}),
assets: 'assets',
watchFilePaths: [
path.resolve(__dirname, 'src/manifest.json')
],
additionalInputs: [
'hyperchat.html',
'scripts/chat-interceptor.ts',
'scripts/chat-metagetter.ts'
],
disableAutoLaunch: process.env.AUTOLAUNCH !== 'true',
browser,
webExtConfig: {
startUrl: 'https://www.youtube.com/watch?v=jfKfPfyJRdk'
}
}),
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: `HyperChat-${browser}.zip`
})
]
});