forked from nsthorat/elementary-reverb-vst-svelte
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
49 lines (44 loc) · 1.44 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
import {sveltekit} from '@sveltejs/kit/vite';
import {defineConfig, searchForWorkspaceRoot} from 'vite';
import {execSync} from 'node:child_process';
const currentCommit = execSync('git rev-parse --short HEAD').toString();
const date = new Date();
const dateString = `${date.getFullYear()}.${date.getMonth() + 1}.${date.getDate()}`;
// A helper plugin which specifically watches for changes to public/dsp.main.js,
// which is built in a parallel watch job via esbuild during dev.
//
// We can still use Vite's HMR to send a custom reload-dsp event, which is caught
// inside the webview and propagated to native to reinitialize the embedded js engine.
//
// During production builds, this all gets pruned from the bundle.
function pubDirReloadPlugin() {
return {
name: 'pubDirReload',
handleHotUpdate({file, modules, server}: {file: string; modules: any; server: any}) {
if (file.includes('public/dsp.main.js')) {
server.ws.send({
type: 'custom',
event: 'reload-dsp'
});
}
return modules;
}
};
}
export default defineConfig({
define: {
__COMMIT_HASH__: JSON.stringify(currentCommit),
__BUILD_DATE__: JSON.stringify(dateString)
},
plugins: [sveltekit(), pubDirReloadPlugin()],
server: {
fs: {
allow: [
// search up for workspace root
searchForWorkspaceRoot(process.cwd()),
// your custom rules
'./public/manifest.json'
]
}
}
});