forked from wordplaydev/wordplay
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.js
29 lines (26 loc) · 933 Bytes
/
vite.config.js
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
import { sveltekit } from '@sveltejs/kit/vite';
/**
* Make a little plugin that checks for locale file changes and fires an event.
* The event is handled in database.ts, where locales are cached.
*/
function LocaleHotReload() {
return {
name: 'locale-hot-reload',
// @ts-expect-error This is a Vite API, and eslint is warning on missing types, but this is not a TypeScript file.
handleHotUpdate({ file, server }) {
if (file.includes('locales') && file.endsWith('.json')) {
console.log(`${file} changed, sending update event.`);
server.ws.send({
type: 'custom',
event: 'locales-update',
});
}
},
};
}
/** @type {import('vite').UserConfig} */
const config = {
plugins: [sveltekit(), LocaleHotReload()],
build: { chunkSizeWarningLimit: 1600 },
};
export default config;