-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathvite.config.ts
More file actions
54 lines (50 loc) · 1.41 KB
/
vite.config.ts
File metadata and controls
54 lines (50 loc) · 1.41 KB
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
/**
* SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: CC0-1.0
*/
import { createLibConfig } from '@nextcloud/vite-config'
import { readdirSync, readFileSync } from 'fs'
import { po as poParser } from 'gettext-parser'
const translations = readdirSync('./l10n')
.filter((name: string) => name !== 'messages.pot' && name.endsWith('.pot'))
.map((file: string) => {
const path = './l10n/' + file
const language = file.slice(0, -'.pot'.length)
const po = readFileSync(path)
const json = poParser.parse(po)
// compress the translations
const translations = Object.entries(json.translations[''])
.filter(([key]) => key)
.map(([, value]) => value)
return {
language,
translations,
}
})
.filter(({ translations }) => translations.length > 1)
export default createLibConfig({
index: 'lib/index.ts',
}, {
config: {
build: {
cssCodeSplit: false,
},
},
libraryFormats: ['es'],
// Packages that should be externalized or bundled
nodeExternalsOptions: {
// for subpath imports like '@nextcloud/l10n/gettext'
include: [/^@nextcloud\//],
exclude: [
// we should not rely on external vue SFC dependencies thus bundle all .vue files
/^vue-material-design-icons\//,
/\.vue(\?|$)/,
// and bundle raw data, e.g., raw SVGs
/\?raw$/,
],
},
// Inject our translations
replace: {
__TRANSLATIONS__: JSON.stringify(translations),
},
})