aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/watch.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/scripts/watch.js b/scripts/watch.js
index 8ea5f29..be05f2b 100644
--- a/scripts/watch.js
+++ b/scripts/watch.js
@@ -191,6 +191,25 @@ function setupMainPackageWatcher(viteDevServer) {
191} 191}
192 192
193/** 193/**
194 * @param {(event: import('vite').HMRPayload) => void} sendEvent
195 */
196function setupTranslationsWatcher(sendEvent) {
197 const localesDir = path.join(thisDir, '../locales');
198 const watcher = watch(localesDir, {
199 ignored: /\.missing\.json$/,
200 ignoreInitial: true,
201 persistent: true,
202 });
203 watcher.on('change', () => {
204 console.log(`\u26A1 Reloading translations`);
205 sendEvent({
206 type: 'custom',
207 event: 'sophie:reload-translations',
208 });
209 });
210}
211
212/**
194 * @returns {Promise<void>} 213 * @returns {Promise<void>}
195 */ 214 */
196async function setupDevEnvironment() { 215async function setupDevEnvironment() {
@@ -246,6 +265,8 @@ async function setupDevEnvironment() {
246 return; 265 return;
247 } 266 }
248 267
268 setupTranslationsWatcher(sendEvent);
269
249 console.log('\uD83C\uDF80 Sophie is starting up'); 270 console.log('\uD83C\uDF80 Sophie is starting up');
250 await setupMainPackageWatcher(viteDevServer); 271 await setupMainPackageWatcher(viteDevServer);
251} 272}