-
Notifications
You must be signed in to change notification settings - Fork 9
/
vite.config.ts
60 lines (57 loc) · 1.64 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
50
51
52
53
54
55
56
57
58
59
60
/**
* 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'
import { defineConfig, type UserConfigFn } from 'vite'
const translations = readdirSync('./l10n')
.filter(name => name !== 'messages.pot' && name.endsWith('.pot'))
.map(file => {
const path = './l10n/' + file
const locale = file.slice(0, -'.pot'.length)
const po = readFileSync(path)
const json = poParser.parse(po)
return {
locale,
json,
}
})
export default defineConfig((env) => {
return createLibConfig({
index: 'lib/index.ts',
filepicker: 'lib/filepicker.ts',
}, {
config: {
build: {
// Fix for vite config, TODO: remove with next release
cssCodeSplit: false,
},
},
// We build for ESM and legacy common js
libraryFormats: ['es', 'cjs'],
// We want one single output CSS file
inlineCSS: false,
// 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),
},
// Rollup our type definitions to only publish what it needed
DTSPluginOptions: {
rollupTypes: env.mode === 'production',
},
})(env)
}) as UserConfigFn