2023-10-20 16:15:28 +03:00
|
|
|
/// <reference types="vitest" />
|
|
|
|
import vue from '@vitejs/plugin-vue'
|
2024-06-02 17:27:42 +03:00
|
|
|
import { resolve } from 'node:path'
|
2023-10-20 16:15:28 +03:00
|
|
|
import { fileURLToPath, URL } from 'node:url'
|
2022-12-08 11:19:29 +03:00
|
|
|
import { defineConfig, loadEnv } from 'vite'
|
2024-03-08 17:31:09 +03:00
|
|
|
import topLevelAwait from 'vite-plugin-top-level-await'
|
2024-06-02 17:27:42 +03:00
|
|
|
import vuetify from 'vite-plugin-vuetify'
|
2022-11-15 11:36:54 +03:00
|
|
|
|
2023-10-20 16:15:28 +03:00
|
|
|
// https://vitejs.dev/config/
|
2023-12-21 07:07:46 +03:00
|
|
|
export default defineConfig(({ mode }) => {
|
2023-10-20 16:15:28 +03:00
|
|
|
const env = loadEnv(mode, process.cwd())
|
2024-10-18 10:21:52 +03:00
|
|
|
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
|
|
|
|
2022-12-08 11:19:29 +03:00
|
|
|
return {
|
2023-01-24 19:10:59 +03:00
|
|
|
base: './',
|
|
|
|
build: {
|
|
|
|
target: 'esnext',
|
2024-05-18 11:26:02 +03:00
|
|
|
outDir: mode === 'demo' ? './vuetorrent-demo' : './vuetorrent/public',
|
2023-01-24 19:10:59 +03:00
|
|
|
rollupOptions: {
|
|
|
|
output: {
|
|
|
|
manualChunks: {
|
2023-11-09 16:39:08 +03:00
|
|
|
// apexcharts: ['apexcharts', 'vue3-apexcharts'],
|
2024-04-15 13:25:00 +03:00
|
|
|
vue: ['vue', 'vue-router', 'vue-i18n', 'vue3-toastify', 'vuedraggable', 'pinia', 'pinia-persistence-plugin'],
|
2023-11-09 06:26:41 +03:00
|
|
|
vuetify: ['vuetify']
|
2023-01-24 19:10:59 +03:00
|
|
|
}
|
|
|
|
}
|
2023-10-20 16:15:28 +03:00
|
|
|
}
|
2023-01-24 19:10:59 +03:00
|
|
|
},
|
|
|
|
define: {
|
2023-12-21 07:07:46 +03:00
|
|
|
'import.meta.env.VITE_PACKAGE_VERSION': JSON.stringify(process.env.npm_package_version),
|
2023-01-24 19:10:59 +03:00
|
|
|
'process.env': {}
|
2022-12-08 11:19:29 +03:00
|
|
|
},
|
2024-03-08 17:31:09 +03:00
|
|
|
plugins: [
|
|
|
|
vue(),
|
|
|
|
vuetify(),
|
|
|
|
topLevelAwait({
|
|
|
|
promiseExportName: '__tla',
|
2024-06-11 00:42:21 +03:00
|
|
|
promiseImportName: i => `__tla_${i}`
|
2024-03-10 05:54:33 +03:00
|
|
|
})
|
|
|
|
],
|
2023-01-24 19:10:59 +03:00
|
|
|
publicDir: './public',
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
2023-10-20 16:15:28 +03:00
|
|
|
'@': fileURLToPath(new URL('./src', import.meta.url))
|
|
|
|
}
|
2022-11-15 11:36:54 +03:00
|
|
|
},
|
2022-12-08 11:19:29 +03:00
|
|
|
server: {
|
2023-02-19 14:28:31 +03:00
|
|
|
host: '0.0.0.0',
|
|
|
|
port: 3000,
|
2022-12-08 11:19:29 +03:00
|
|
|
proxy: {
|
2023-10-20 16:15:28 +03:00
|
|
|
'/api': {
|
2024-06-02 17:27:42 +03:00
|
|
|
secure: false,
|
2024-10-18 10:21:52 +03:00
|
|
|
changeOrigin: true,
|
|
|
|
target: qBittorrentTarget
|
2024-09-19 05:43:47 +03:00
|
|
|
},
|
|
|
|
'/backend': {
|
|
|
|
secure: false,
|
2024-10-18 10:21:52 +03:00
|
|
|
changeOrigin: true,
|
|
|
|
target: backendTarget
|
2023-10-20 16:15:28 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
test: {
|
|
|
|
environment: 'jsdom',
|
2024-04-25 14:26:39 +03:00
|
|
|
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']
|
|
|
|
}
|
2022-12-08 11:19:29 +03:00
|
|
|
}
|
2022-11-15 11:36:54 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|