2022-12-08 11:19:29 +03:00
|
|
|
import { defineConfig, loadEnv } from 'vite'
|
2022-11-15 11:36:54 +03:00
|
|
|
import vue from '@vitejs/plugin-vue2'
|
|
|
|
import { VitePWA } from 'vite-plugin-pwa'
|
|
|
|
import Components from 'unplugin-vue-components/vite'
|
|
|
|
import { VuetifyResolver } from 'unplugin-vue-components/resolvers'
|
|
|
|
|
|
|
|
import { fileURLToPath, URL } from 'node:url'
|
|
|
|
|
|
|
|
const version = process.env.NODE_ENV === 'production' ? process.env.npm_package_version : JSON.stringify(process.env.npm_package_version)
|
|
|
|
|
2023-06-26 10:06:28 +03:00
|
|
|
export default defineConfig(({ mode }) => {
|
2022-12-08 11:19:29 +03:00
|
|
|
const theEnv = loadEnv(mode, process.cwd())
|
|
|
|
const qBittorrentPort = theEnv.VITE_QBITTORRENT_PORT ?? 8080
|
|
|
|
const proxyTarget = theEnv.VITE_QBITTORRENT_TARGET ?? 'http://127.0.0.1'
|
|
|
|
|
|
|
|
return {
|
2023-01-24 19:10:59 +03:00
|
|
|
base: './',
|
|
|
|
build: {
|
|
|
|
target: 'esnext',
|
|
|
|
rollupOptions: {
|
|
|
|
output: {
|
|
|
|
manualChunks: {
|
2023-01-27 17:05:45 +03:00
|
|
|
vue: ['vue', 'vue-router', 'vue-router/composables', 'vuex', 'vuex-persist']
|
2023-01-24 19:10:59 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
outDir: './vuetorrent/public'
|
|
|
|
},
|
|
|
|
define: {
|
|
|
|
'import.meta.env.VITE_PACKAGE_VERSION': version,
|
|
|
|
'process.env': {}
|
2022-12-08 11:19:29 +03:00
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
vue(),
|
|
|
|
Components({
|
|
|
|
dts: false,
|
|
|
|
directives: false,
|
|
|
|
resolvers: [VuetifyResolver()],
|
|
|
|
types: [
|
2022-11-15 11:36:54 +03:00
|
|
|
{
|
2022-12-08 11:19:29 +03:00
|
|
|
from: 'vue-router',
|
|
|
|
names: ['RouterLink', 'RouterView']
|
2022-11-15 11:36:54 +03:00
|
|
|
}
|
|
|
|
]
|
2022-12-08 11:19:29 +03:00
|
|
|
}),
|
|
|
|
VitePWA({
|
|
|
|
includeAssets: [
|
|
|
|
'favicon.ico',
|
2023-06-26 10:06:28 +03:00
|
|
|
'icon.svg',
|
|
|
|
'icon-192.png',
|
|
|
|
'icon-512.png',
|
|
|
|
'robots.txt'
|
2022-12-08 11:19:29 +03:00
|
|
|
],
|
|
|
|
manifest: {
|
|
|
|
name: 'VueTorrent',
|
|
|
|
short_name: 'VueTorrent',
|
|
|
|
theme_color: '#597566',
|
|
|
|
start_url: '.',
|
|
|
|
background_color: '#000',
|
|
|
|
icons: [
|
2023-06-26 10:06:28 +03:00
|
|
|
{ "src": "./icon-192.png", "type": "image/png", "sizes": "192x192" },
|
|
|
|
{ "src": "./icon-512.png", "type": "image/png", "sizes": "512x512" }
|
2022-12-08 11:19:29 +03:00
|
|
|
]
|
|
|
|
},
|
|
|
|
// Other options
|
|
|
|
registerType: 'autoUpdate',
|
|
|
|
base: './',
|
|
|
|
useCredentials: true,
|
|
|
|
workbox: {
|
|
|
|
skipWaiting: true,
|
|
|
|
globPatterns: ['**/*.{js,css,html,ico,png,svg}']
|
2022-11-15 11:36:54 +03:00
|
|
|
}
|
2022-12-08 11:19:29 +03:00
|
|
|
})
|
|
|
|
],
|
2023-01-24 19:10:59 +03:00
|
|
|
publicDir: './public',
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
|
|
|
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
|
|
|
'~': fileURLToPath(new URL('./node_modules', import.meta.url))
|
2022-12-08 11:19:29 +03:00
|
|
|
},
|
2023-01-24 19:10:59 +03:00
|
|
|
extensions: ['.js', '.json', '.jsx', '.ts', '.tsx', '.vue']
|
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: {
|
|
|
|
'/api': `${proxyTarget}:${qBittorrentPort}`
|
|
|
|
}
|
2022-11-15 11:36:54 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|