2023-05-20 11:43:21 +00:00
|
|
|
import { visualizer } from 'rollup-plugin-visualizer'
|
2023-01-30 19:41:49 +00:00
|
|
|
import { defineConfig, type PluginOption } from 'vite'
|
2022-04-30 13:25:59 +00:00
|
|
|
import { VitePWA } from 'vite-plugin-pwa'
|
2023-12-11 14:00:00 +00:00
|
|
|
import { fileURLToPath, URL } from 'node:url'
|
|
|
|
import UnoCSS from 'unocss/vite'
|
2022-02-21 14:07:07 +00:00
|
|
|
|
2022-12-17 17:21:41 +00:00
|
|
|
import manifest from './pwa-manifest.json'
|
2023-05-20 11:43:21 +00:00
|
|
|
|
|
|
|
import VueI18n from '@intlify/unplugin-vue-i18n/vite'
|
|
|
|
import Vue from '@vitejs/plugin-vue'
|
2023-09-01 12:09:58 +00:00
|
|
|
import VueMacros from 'unplugin-vue-macros/vite'
|
2023-12-04 17:32:06 +00:00
|
|
|
import { nodePolyfills } from 'vite-plugin-node-polyfills'
|
2024-10-21 08:55:55 +00:00
|
|
|
import vueDevTools from 'vite-plugin-vue-devtools'
|
2022-02-21 14:07:07 +00:00
|
|
|
|
2024-12-10 11:29:47 +00:00
|
|
|
const port = +(process.env.VUE_PORT ?? 8080)
|
2022-06-23 17:21:06 +00:00
|
|
|
|
2022-02-21 14:07:07 +00:00
|
|
|
// https://vitejs.dev/config/
|
2022-07-31 19:40:31 +00:00
|
|
|
export default defineConfig(({ mode }) => ({
|
2024-01-24 18:17:52 +00:00
|
|
|
envPrefix: ['VUE_', 'TAURI_', 'FUNKWHALE_SENTRY_'],
|
2022-02-21 22:16:48 +00:00
|
|
|
plugins: [
|
2023-09-01 12:09:58 +00:00
|
|
|
// https://vue-macros.sxzz.moe/
|
|
|
|
VueMacros({
|
|
|
|
plugins: {
|
|
|
|
// https://github.com/vitejs/vite/tree/main/packages/plugin-vue
|
2024-02-20 14:39:55 +00:00
|
|
|
vue: Vue()
|
2023-09-01 12:09:58 +00:00
|
|
|
}
|
|
|
|
}),
|
2022-07-31 19:40:31 +00:00
|
|
|
|
2022-09-10 16:31:48 +00:00
|
|
|
// https://github.com/intlify/bundle-tools/tree/main/packages/vite-plugin-vue-i18n
|
|
|
|
VueI18n({
|
2023-12-11 14:00:00 +00:00
|
|
|
include: fileURLToPath(new URL('./src/locales/**', import.meta.url))
|
2022-09-10 16:31:48 +00:00
|
|
|
}),
|
|
|
|
|
2023-01-30 19:41:49 +00:00
|
|
|
// https://github.com/btd/rollup-plugin-visualizer
|
|
|
|
visualizer() as unknown as PluginOption,
|
|
|
|
|
2022-04-30 13:25:59 +00:00
|
|
|
// https://github.com/antfu/vite-plugin-pwa
|
|
|
|
VitePWA({
|
|
|
|
strategies: 'injectManifest',
|
|
|
|
srcDir: 'src',
|
|
|
|
filename: 'serviceWorker.ts',
|
2022-07-25 18:41:03 +00:00
|
|
|
manifestFilename: 'manifest.json',
|
2022-04-30 13:25:59 +00:00
|
|
|
devOptions: {
|
|
|
|
enabled: true,
|
|
|
|
type: 'module',
|
2022-07-25 18:41:03 +00:00
|
|
|
navigateFallback: 'index.html'
|
2022-10-13 19:03:06 +00:00
|
|
|
},
|
2022-12-17 17:21:41 +00:00
|
|
|
manifest
|
2023-12-04 17:32:06 +00:00
|
|
|
}),
|
|
|
|
|
|
|
|
// https://github.com/davidmyersdev/vite-plugin-node-polyfills
|
|
|
|
// see: https://github.com/Borewit/music-metadata-browser/issues/836
|
2023-12-11 14:00:00 +00:00
|
|
|
nodePolyfills(),
|
|
|
|
|
|
|
|
|
|
|
|
// https://unocss.dev/
|
2024-10-21 08:55:55 +00:00
|
|
|
UnoCSS(),
|
|
|
|
vueDevTools(),
|
2022-06-23 17:21:06 +00:00
|
|
|
],
|
2022-07-21 14:13:42 +00:00
|
|
|
server: {
|
2024-10-29 11:49:05 +00:00
|
|
|
port: +(process.env.VUE_PORT ?? 8080),
|
|
|
|
watch: {
|
|
|
|
usePolling: true,
|
|
|
|
}
|
2022-07-21 14:13:42 +00:00
|
|
|
},
|
2022-02-21 14:07:07 +00:00
|
|
|
resolve: {
|
2023-12-11 14:00:00 +00:00
|
|
|
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)) },
|
|
|
|
]
|
2022-04-02 17:38:14 +00:00
|
|
|
},
|
2024-12-04 15:25:37 +00:00
|
|
|
css: {
|
|
|
|
preprocessorOptions: {
|
|
|
|
scss: {
|
|
|
|
additionalData: `
|
|
|
|
$docs: ${!!process.env.VP_DOCS};
|
2024-12-06 12:47:24 +00:00
|
|
|
@use "~/style/_vars" as *;
|
|
|
|
@import "~/style/inc/theme";
|
|
|
|
@import "~/style/funkwhale";
|
2024-12-04 15:25:37 +00:00
|
|
|
`
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2023-01-30 19:41:20 +00:00
|
|
|
build: {
|
2023-09-01 12:09:58 +00:00
|
|
|
sourcemap: true,
|
2023-01-30 19:41:20 +00:00
|
|
|
// https://rollupjs.org/configuration-options/
|
|
|
|
rollupOptions: {
|
|
|
|
output: {
|
|
|
|
manualChunks: {
|
2024-02-20 14:39:55 +00:00
|
|
|
axios: ['axios', 'axios-auth-refresh'],
|
|
|
|
dompurify: ['dompurify'],
|
|
|
|
jquery: ['jquery'],
|
|
|
|
lodash: ['lodash-es'],
|
|
|
|
moment: ['moment'],
|
|
|
|
sentry: ['@sentry/vue', '@sentry/tracing'],
|
2023-01-30 19:41:20 +00:00
|
|
|
'standardized-audio-context': ['standardized-audio-context'],
|
2024-02-20 14:39:55 +00:00
|
|
|
'vue-router': ['vue-router']
|
2023-01-30 19:41:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2022-08-31 22:36:40 +00:00
|
|
|
test: {
|
|
|
|
environment: 'jsdom',
|
2022-09-15 17:37:44 +00:00
|
|
|
globals: true,
|
2023-06-11 09:29:39 +00:00
|
|
|
reporters: ['default', 'junit'],
|
2024-02-20 14:39:55 +00:00
|
|
|
outputFile: './test_results.xml',
|
2022-09-15 17:37:44 +00:00
|
|
|
coverage: {
|
|
|
|
src: './src',
|
|
|
|
all: true,
|
|
|
|
reporter: ['text', 'cobertura']
|
2023-05-06 10:25:33 +00:00
|
|
|
},
|
|
|
|
setupFiles: [
|
2024-02-20 14:39:55 +00:00
|
|
|
'./test/setup/mock-server.ts',
|
2023-05-06 10:25:33 +00:00
|
|
|
'./test/setup/mock-audio-context.ts',
|
2024-02-20 14:39:55 +00:00
|
|
|
'./test/setup/mock-vue-i18n.ts',
|
|
|
|
'./test/setup/mock-lru-cache.ts'
|
2023-05-06 10:25:33 +00:00
|
|
|
]
|
2022-06-13 09:53:36 +00:00
|
|
|
}
|
2022-04-17 22:43:58 +00:00
|
|
|
}))
|