VueTorrent/vite.config.ts

91 lines
2.4 KiB
TypeScript
Raw Normal View History

2023-10-20 16:15:28 +03:00
/// <reference types="vitest" />
import vue from '@vitejs/plugin-vue'
import { fileURLToPath, URL } from 'node:url'
import { defineConfig, loadEnv } from 'vite'
2023-10-20 16:15:28 +03:00
import vuetify from 'vite-plugin-vuetify'
import { VitePWA } from 'vite-plugin-pwa'
2023-10-20 16:15:28 +03:00
import { resolve } from 'node:path'
2023-10-20 16:15:28 +03:00
// https://vitejs.dev/config/
2023-06-26 10:06:28 +03:00
export default defineConfig(({ mode }) => {
2023-10-20 16:15:28 +03:00
const env = loadEnv(mode, process.cwd())
const qBittorrentPort = env.VITE_QBITTORRENT_PORT ?? '8080'
const proxyTarget = env.VITE_QBITTORRENT_TARGET ?? 'http://127.0.0.1'
const version = process.env.NODE_ENV === 'production' ? process.env.npm_package_version : JSON.stringify(process.env.npm_package_version)
return {
base: './',
build: {
target: 'esnext',
2023-10-20 16:15:28 +03:00
outDir: './vuetorrent/public',
rollupOptions: {
output: {
manualChunks: {
2023-10-20 16:15:28 +03:00
vue: ['vue', 'vue-router']
}
}
2023-10-20 16:15:28 +03:00
}
},
define: {
'import.meta.env.VITE_PACKAGE_VERSION': version,
'process.env': {}
},
plugins: [
vue(),
2023-10-20 16:15:28 +03:00
vuetify(),
VitePWA({
includeAssets: ['favicon.ico', 'icon.svg', 'icon-192.png', 'icon-512.png', 'robots.txt'],
manifest: {
name: 'VueTorrent',
short_name: 'VueTorrent',
theme_color: '#597566',
start_url: '.',
background_color: '#000',
icons: [
{ src: './icon-192.png', type: 'image/png', sizes: '192x192' },
{ src: './icon-512.png', type: 'image/png', sizes: '512x512' }
]
},
// Other options
registerType: 'autoUpdate',
base: './',
useCredentials: true,
workbox: {
2023-08-11 14:16:49 +03:00
maximumFileSizeToCacheInBytes: 10000000,
skipWaiting: true,
2023-08-11 14:17:10 +03:00
globPatterns: ['**/*.{js,css,html,ico,png,svg,woff,woff2}']
}
})
],
publicDir: './public',
resolve: {
alias: {
2023-10-20 16:15:28 +03:00
'@': fileURLToPath(new URL('./src', import.meta.url))
}
},
server: {
2023-02-19 14:28:31 +03:00
host: '0.0.0.0',
port: 3000,
proxy: {
2023-10-20 16:15:28 +03:00
'/api': {
target: `${proxyTarget}:${qBittorrentPort}`,
secure: false
}
}
},
test: {
environment: 'jsdom',
setupFiles: [resolve(__dirname, 'tests/setup.ts')],
coverage: {
reportsDirectory: './tests/unit/coverage'
},
server: {
deps: {
inline: ['vuetify']
}
}
}
}
})