funkwhale/front/vite.config.ts

121 wiersze
3.3 KiB
TypeScript

import { visualizer } from 'rollup-plugin-visualizer'
import { defineConfig, type PluginOption } from 'vite'
import { VitePWA } from 'vite-plugin-pwa'
import { fileURLToPath, URL } from 'node:url'
import UnoCSS from 'unocss/vite'
import manifest from './pwa-manifest.json'
import VueI18n from '@intlify/unplugin-vue-i18n/vite'
import Vue from '@vitejs/plugin-vue'
import VueMacros from 'unplugin-vue-macros/vite'
import { nodePolyfills } from 'vite-plugin-node-polyfills'
import vueDevTools from 'vite-plugin-vue-devtools'
const port = +(process.env.VUE_PORT ?? 8080)
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => ({
envPrefix: ['VUE_', 'TAURI_', 'FUNKWHALE_SENTRY_'],
plugins: [
// https://vue-macros.sxzz.moe/
VueMacros({
plugins: {
// https://github.com/vitejs/vite/tree/main/packages/plugin-vue
vue: Vue()
}
}),
// https://github.com/intlify/bundle-tools/tree/main/packages/vite-plugin-vue-i18n
VueI18n({
include: fileURLToPath(new URL('./src/locales/**', import.meta.url))
}),
// https://github.com/btd/rollup-plugin-visualizer
visualizer() as unknown as PluginOption,
// https://github.com/antfu/vite-plugin-pwa
VitePWA({
strategies: 'injectManifest',
srcDir: 'src',
filename: 'serviceWorker.ts',
manifestFilename: 'manifest.json',
devOptions: {
enabled: true,
type: 'module',
navigateFallback: 'index.html'
},
manifest
}),
// https://github.com/davidmyersdev/vite-plugin-node-polyfills
// see: https://github.com/Borewit/music-metadata-browser/issues/836
nodePolyfills(),
// https://unocss.dev/
UnoCSS(),
vueDevTools(),
],
server: {
port: +(process.env.VUE_PORT ?? 8080),
watch: {
usePolling: true,
}
},
resolve: {
alias: [
{ find: '#', replacement: fileURLToPath(new URL('./src/ui/workers', import.meta.url)) },
{ find: '?', replacement: fileURLToPath(new URL('./test', import.meta.url)) },
{ find: '~', replacement: fileURLToPath(new URL('./src', import.meta.url)) },
]
},
css: {
preprocessorOptions: {
scss: {
additionalData: `
$docs: ${!!process.env.VP_DOCS};
@use "~/style/_vars" as *;
@import "~/style/inc/theme";
@import "~/style/funkwhale";
`
}
}
},
build: {
sourcemap: true,
// https://rollupjs.org/configuration-options/
rollupOptions: {
output: {
manualChunks: {
axios: ['axios', 'axios-auth-refresh'],
dompurify: ['dompurify'],
jquery: ['jquery'],
lodash: ['lodash-es'],
moment: ['moment'],
sentry: ['@sentry/vue', '@sentry/tracing'],
'standardized-audio-context': ['standardized-audio-context'],
'vue-router': ['vue-router']
}
}
}
},
test: {
environment: 'jsdom',
globals: true,
reporters: ['default', 'junit'],
outputFile: './test_results.xml',
coverage: {
src: './src',
all: true,
reporter: ['text', 'cobertura']
},
setupFiles: [
'./test/setup/mock-server.ts',
'./test/setup/mock-audio-context.ts',
'./test/setup/mock-vue-i18n.ts',
'./test/setup/mock-lru-cache.ts'
]
}
}))