nextcloud-dialogs/vite.config.ts

73 строки
1.8 KiB
TypeScript
Исходник Обычный вид История

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,
},
// vitest configuration
test: {
environment: 'happy-dom',
coverage: {
all: true,
provider: 'v8',
include: ['lib/**/*.ts', 'lib/*.ts'],
exclude: ['lib/**/*.spec.ts'],
},
css: {
modules: {
classNameStrategy: 'non-scoped',
},
},
// Fix unresolvable .css extension for ssr
server: {
deps: {
inline: [/@nextcloud\/vue/],
},
},
},
},
// 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\//],
// we should externalize vue SFC dependencies
exclude: [/^vue-material-design-icons\//, /\.vue(\?|$)/],
},
// 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