2023-07-20 16:43:40 +03:00
|
|
|
import { createLibConfig } from '@nextcloud/vite-config'
|
2023-07-13 02:57:39 +03:00
|
|
|
import { readdirSync, readFileSync } from 'fs'
|
|
|
|
import gettextParser from 'gettext-parser'
|
|
|
|
import { defineConfig } from 'vite'
|
|
|
|
|
2023-07-20 16:43:40 +03:00
|
|
|
const translations = readdirSync('./l10n')
|
2023-07-13 02:57:39 +03:00
|
|
|
.filter(name => name !== 'messages.pot' && name.endsWith('.pot'))
|
|
|
|
.map(file => {
|
|
|
|
const path = './l10n/' + file
|
|
|
|
const locale = file.slice(0, -'.pot'.length)
|
|
|
|
|
2023-07-20 16:43:40 +03:00
|
|
|
const po = readFileSync(path)
|
|
|
|
const json = gettextParser.po.parse(po)
|
2023-07-13 02:57:39 +03:00
|
|
|
return {
|
|
|
|
locale,
|
|
|
|
json,
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
export default defineConfig((env) => {
|
|
|
|
return createLibConfig({
|
2023-08-09 22:27:35 +03:00
|
|
|
index: 'lib/index.ts',
|
|
|
|
legacy: 'lib/legacy.ts',
|
2023-07-13 02:57:39 +03:00
|
|
|
}, {
|
|
|
|
inlineCSS: false,
|
2023-07-20 16:43:40 +03:00
|
|
|
config: {
|
|
|
|
build: {
|
|
|
|
// Fix for vite config, TODO: remove with next release
|
|
|
|
cssCodeSplit: false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
nodeExternalsOptions: {
|
|
|
|
include: [/^@nextcloud\//],
|
|
|
|
},
|
2023-07-13 02:57:39 +03:00
|
|
|
libraryFormats: ['es', 'cjs'],
|
|
|
|
replace: {
|
2023-07-20 16:43:40 +03:00
|
|
|
__TRANSLATIONS__: JSON.stringify(translations),
|
2023-07-13 02:57:39 +03:00
|
|
|
},
|
|
|
|
DTSPluginOptions: {
|
|
|
|
rollupTypes: env.mode === 'production',
|
2023-07-20 16:43:40 +03:00
|
|
|
},
|
2023-07-13 02:57:39 +03:00
|
|
|
})(env)
|
2023-07-20 16:43:40 +03:00
|
|
|
})
|