Use vite to replace webpack
This commit is contained in:
parent
9dcdd421ac
commit
25de264abb
51 changed files with 1210 additions and 79 deletions
24
build/service_worker_messages.js
Normal file
24
build/service_worker_messages.js
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import { languages, langCodeToJsonName } from '../src/i18n/languages.js'
|
||||
import { readFile } from 'node:fs/promises'
|
||||
import { dirname, resolve } from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
|
||||
export const generateServiceWorkerMessages = async () => {
|
||||
const i18nDir = resolve(
|
||||
dirname(dirname(fileURLToPath(import.meta.url))),
|
||||
'src/i18n'
|
||||
)
|
||||
const msgArray = await Promise.all(languages.map(async lang => {
|
||||
const name = langCodeToJsonName(lang)
|
||||
const file = resolve(i18nDir, name + '.json')
|
||||
const fileContent = await readFile(file, 'utf-8')
|
||||
const msg = {
|
||||
notifications: JSON.parse(fileContent).notifications || {}
|
||||
}
|
||||
return [lang, msg]
|
||||
}))
|
||||
return msgArray.reduce((acc, [lang, msg]) => {
|
||||
acc[lang] = msg
|
||||
return acc
|
||||
}, {})
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue