VueTorrent/vite.config.ts

79 lines
2 KiB
TypeScript
Raw Normal View History

2023-10-20 16:15:28 +03:00
/// <reference types="vitest" />
import vue from '@vitejs/plugin-vue'
import { resolve } from 'node:path'
2023-10-20 16:15:28 +03:00
import { fileURLToPath, URL } from 'node:url'
import { defineConfig, loadEnv } from 'vite'
import topLevelAwait from 'vite-plugin-top-level-await'
import vuetify from 'vite-plugin-vuetify'
2023-10-20 16:15:28 +03:00
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
2023-10-20 16:15:28 +03:00
const env = loadEnv(mode, process.cwd())
const qBittorrentTarget = env.VITE_QBITTORRENT_TARGET ?? 'http://localhost:8080'
const backendTarget = env.VITE_BACKEND_TARGET ?? 'http://localhost:3000'
2023-10-20 16:15:28 +03:00
return {
base: './',
build: {
target: 'esnext',
outDir: mode === 'demo' ? './vuetorrent-demo' : './vuetorrent/public',
rollupOptions: {
output: {
manualChunks: {
2023-11-09 16:39:08 +03:00
// apexcharts: ['apexcharts', 'vue3-apexcharts'],
vue: ['vue', 'vue-router', 'vue-i18n', 'vue3-toastify', 'vuedraggable', 'pinia', 'pinia-persistence-plugin'],
vuetify: ['vuetify']
}
}
2023-10-20 16:15:28 +03:00
}
},
define: {
'import.meta.env.VITE_PACKAGE_VERSION': JSON.stringify(process.env.npm_package_version),
'process.env': {}
},
plugins: [
vue(),
vuetify(),
topLevelAwait({
promiseExportName: '__tla',
promiseImportName: i => `__tla_${i}`
2024-03-10 05:54:33 +03:00
})
],
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': {
secure: false,
changeOrigin: true,
target: qBittorrentTarget
},
'/backend': {
secure: false,
changeOrigin: true,
target: backendTarget
2023-10-20 16:15:28 +03:00
}
}
},
test: {
environment: 'jsdom',
globals: true,
2023-10-20 16:15:28 +03:00
setupFiles: [resolve(__dirname, 'tests/setup.ts')],
coverage: {
reportsDirectory: './tests/unit/coverage'
},
server: {
deps: {
inline: ['vuetify']
}
}
}
}
})